[file libraries] Write to disk feature

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[file libraries] Write to disk feature

Sebastian Sastre-2
Hi there,
 
    there is a bug in writing libraries to disk (a conditional for binary and plain text is inverted). Here is a patch I'm using:
 
SeasidePlatformSupport>>write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
 "Writes aStringOrByteArray to a file named aFilenameString in the folder aFolderString.
 Note: if aStringOrByteArray is a string it writes a CR LF kind of file and binary otherwise"

 | folder stream fullFilePath |
 folder := FileDirectory default directoryNamed: aFolderString.
 fullFilePath := folder fullNameFor: aFileNameString.
 stream := aStringOrByteArray isString
  ifTrue: [ (CrLfFileStream forceNewFileNamed: fullFilePath) binary ]
  ifFalse: [ (FileStream forceNewFileNamed: fullFilePath) ascii ].
 [ stream nextPutAll: aStringOrByteArray ]
  ensure: [ stream close ]
 
    cheers,
 

Sebastian Sastre

 

 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: [file libraries] Write to disk feature (bugfix for the bugfix)

Sebastian Sastre-2
Please ignore my previous buggy bugfix :P
 
Here is one that was tested:
 
write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
 "Writes aStringOrByteArray to a file named aFilenameString in the folder aFolderString.
 Note: if aStringOrByteArray is a string it writes a CR LF kind of file and binary otherwise"
 | folder stream fullFilePath |
 folder := FileDirectory default directoryNamed: aFolderString.
 fullFilePath := folder fullNameFor: aFileNameString.
 stream := aStringOrByteArray isString
  ifTrue: [ (CrLfFileStream forceNewFileNamed: fullFilePath) ascii]
  ifFalse: [ (FileStream forceNewFileNamed: fullFilePath) binary].
 [ stream nextPutAll: aStringOrByteArray ]
  ensure: [ stream close ]
 
It's not a big thing but will be friendly for the web interface that one could select several libraries and press a button like "write to disk selected libraries"
 
    cheers,
 

Sebastian Sastre

 
 

De: [hidden email] [mailto:[hidden email]] En nombre de Sebastian Sastre
Enviado el: MiƩrcoles, 22 de Agosto de 2007 17:14
Para: 'Seaside - general discussion'
Asunto: [Seaside] [file libraries] Write to disk feature

Hi there,
 
    there is a bug in writing libraries to disk (a conditional for binary and plain text is inverted). Here is a patch I'm using:
 
SeasidePlatformSupport>>write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
 "Writes aStringOrByteArray to a file named aFilenameString in the folder aFolderString.
 Note: if aStringOrByteArray is a string it writes a CR LF kind of file and binary otherwise"

 | folder stream fullFilePath |
 folder := FileDirectory default directoryNamed: aFolderString.
 fullFilePath := folder fullNameFor: aFileNameString.
 stream := aStringOrByteArray isString
  ifTrue: [ (CrLfFileStream forceNewFileNamed: fullFilePath) binary ]
  ifFalse: [ (FileStream forceNewFileNamed: fullFilePath) ascii ].
 [ stream nextPutAll: aStringOrByteArray ]
  ensure: [ stream close ]
 
    cheers,
 

Sebastian Sastre

 

 

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [file libraries] Write to disk feature (bugfix for the bugfix)

Philippe Marschall
2007/8/22, Sebastian Sastre <[hidden email]>:

>
>
> Please ignore my previous buggy bugfix :P
>
> Here is one that was tested:
>
> write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
>  "Writes aStringOrByteArray to a file named aFilenameString in the folder
> aFolderString.
>  Note: if aStringOrByteArray is a string it writes a CR LF kind of file and
> binary otherwise"
>  | folder stream fullFilePath |
>  folder := FileDirectory default directoryNamed: aFolderString.
>  fullFilePath := folder fullNameFor: aFileNameString.
>  stream := aStringOrByteArray isString
>   ifTrue: [ (CrLfFileStream forceNewFileNamed: fullFilePath) ascii]
>   ifFalse: [ (FileStream forceNewFileNamed: fullFilePath) binary].
>  [ stream nextPutAll: aStringOrByteArray ]
>   ensure: [ stream close ]
D'oh! Fixed.
Thx

Cheers
Philippe

> It's not a big thing but will be friendly for the web interface that one
> could select several libraries and press a button like "write to disk
> selected libraries"
>
>     cheers,
>
>
>
> Sebastian Sastre
>
>
>
>
>  ________________________________
>
> De: [hidden email]
> [mailto:[hidden email]] En
> nombre de Sebastian Sastre
> Enviado el: MiƩrcoles, 22 de Agosto de 2007 17:14
> Para: 'Seaside - general discussion'
> Asunto: [Seaside] [file libraries] Write to disk feature
>
>
>
>
> Hi there,
>
>     there is a bug in writing libraries to disk (a conditional for binary
> and plain text is inverted). Here is a patch I'm using:
>
> SeasidePlatformSupport>>write: aStringOrByteArray toFile: aFileNameString
> inFolder: aFolderString
>  "Writes aStringOrByteArray to a file named aFilenameString in the folder
> aFolderString.
>  Note: if aStringOrByteArray is a string it writes a CR LF kind of file and
> binary otherwise"
>
>  | folder stream fullFilePath |
>  folder := FileDirectory default directoryNamed: aFolderString.
>  fullFilePath := folder fullNameFor: aFileNameString.
>  stream := aStringOrByteArray isString
>   ifTrue: [ (CrLfFileStream forceNewFileNamed: fullFilePath) binary ]
>   ifFalse: [ (FileStream forceNewFileNamed: fullFilePath) ascii ].
>  [ stream nextPutAll: aStringOrByteArray ]
>   ensure: [ stream close ]
>
>     cheers,
>
>
>
> Sebastian Sastre
>
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside