[Seaside] File Directory error (Pharo 1.2.1)

dtrussardi at tiscali.it dtrussardi at tiscali.it
Wed Dec 14 17:07:26 UTC 2011


	some time ago i found a problem when upload one  	WAFileLibrarySubclass   with the command:

		WAFileLibrarySubclass 	addAllFilesIn: 		'/Dati-IST/ISTWork/ImmaginiBase'
>> ---------------------------------------------------------------------------------------------------------------------------------------------------
>> File Library notes
>> A) when  i do the               WAFileLibrarySubclass   addAllFilesIn:   '/Dati-IST/ISTWork/ImmaginiBase'
>> the method  do loop on files in the path .
>>        addAllFilesIn: aPathString
>>        "adds all files in the directory specified by aPathString to the current file library"
	I confirm this point.

>>        **** THIS LOOP WORK FINE.  The files  exist. ****
>>        (GRPlatform current filesIn: aPathString) do: [ :each | self addFileAt: each ]
>> B) The error is in the action  do on the specific interaction:
>>        addFileAt: aPath
>>        "adds the file specified by aFilename to the current file library"
>>        self
>>                addFileAt: aPath
>>                contents: (GRPlatform current
>>                                contentsOfFile: aPath
>>                                binary: (self isBinaryAt: aPath))

The error is erase into			 contentsOfFile: aString binary: aBoolean   method
		 by :		(FileDirectory default oldFileNamed: aString) 	answer nil

	 because it open  the  file in Read-Wriite mode but the file don't have write authorization.


contentsOfFile: aString binary: aBoolean
	| stream |
	stream := aBoolean
		ifTrue: [ (FileDirectory default oldFileNamed:  aString)

** at this point binary is sent to nil  and error is erase ***

			yourself ]
		ifFalse: [ (MultiByteFileStream oldFileNamed: aString)

** at this point binary is sent to nil  and error is erase ***

			wantsLineEndConversion: true;
			yourself ].
	^ [ stream contents ] ensure: [ stream close ]

I think it's a valid  solution change
				 the:		 oldFileNamed: aString)

				into:   	 readOnlyFileNamed: aString) 

	for open the file only in read modality.


			point one :	 the A) interaction found the files in any case

			point two :  the files can have only read authorization.
			point three : 	 the     contentsOfFile: aString binary: aBoolean 		 is call only by in this step

Any other considerations ?


More information about the seaside mailing list