Hi all,
I found a small problem when trying to access a directory for which I did not have read permission (Linux) using FileDialog. Here's how you can replicate it: create a test directory, say: /home/test and remove your read permission to it (chmod a-rwx /home/test) then, from visual works: SaveFileDialog new defaultDirectory: '/home'; select. try do dive into the 'test' directory to view its contents... an exception is raised. A simple fix would be to add OSErrorHolder >> noPermissionsSignal to the list of expected errors in FileDialog >> currentDirectoryContent, as follows: FileDialog >> currentDirectoryContent | content directory | directory := self directoryHolder value. ^[content := directory directoryContents. content := content collect: [:string | directory constructSafe: string]. "Names with invalid characters may produce Filenames that appear not to exist. Observed under OSX with a filename containing a CR." content := content select: [:some | some exists]. self showHiddenHolder value ifFalse: [content := content reject: [:filename | filename isHidden]]. content := self filterFilenames: content. self resortList: content] on: OsIllegalOperation, OSErrorHolder nonexistentSignal , OSErrorHolder noPermissionsSignal do: [:ex | | errorHolder | "Inaccessible volume; can happen in Windows." errorHolder := ex parameter. self reportFileError: errorHolder. ex return: List new] keep coding, ricardo |
This behavior is quite similar to what I am getting on my Mac laptop,
which has an automount directory mounting a remote drive whenever it is connected to the network. When I am off-line, accessing the file dialogue raises an exception, as Ricardo reports it does on Linux for unreadable dirs. I wonder if there is a similar fix? I would one go about finding out the right exception to handle? On May 8, 2006, at 4:57 PM, Ricardo Birmann wrote: > Hi all, > > I found a small problem when trying to access a directory for which I > did not have read permission (Linux) using FileDialog. Here's how you > can replicate it: > > create a test directory, say: /home/test and remove your read > permission to it (chmod a-rwx /home/test) > > then, from visual works: > > SaveFileDialog new defaultDirectory: '/home'; select. > > try do dive into the 'test' directory to view its contents... an > exception is raised. > > A simple fix would be to add OSErrorHolder >> noPermissionsSignal to > the list of expected errors in FileDialog >> currentDirectoryContent, > as follows: > > FileDialog >> currentDirectoryContent > > | content directory | > directory := self directoryHolder value. > ^[content := directory directoryContents. > content := content collect: [:string | directory constructSafe: > string]. > "Names with invalid characters may produce Filenames that > appear not to exist. > Observed under OSX with a filename containing a CR." > content := content select: [:some | some exists]. > self showHiddenHolder value > ifFalse: [content := content reject: [:filename | filename > isHidden]]. > content := self filterFilenames: content. > self resortList: content] > on: OsIllegalOperation, OSErrorHolder nonexistentSignal , > OSErrorHolder noPermissionsSignal > do: [:ex | | errorHolder | "Inaccessible volume; can happen > in Windows." > errorHolder := ex parameter. > self reportFileError: errorHolder. > ex return: List new] > > > > keep coding, > > ricardo > Stefano Franchi Department of Philosophy Ph: (64) 9 373-7599 x83940 University Of Auckland Fax: (64) 9 373-8768 Private Bag 92019 [hidden email] Auckland New Zealand |
Stefano,
The exception raised in your case might be the same as in mine... either way, you should take a look at the class methods implemented in OSErrorHolder. hope it helps, ricardo On 5/8/06, Stefano Franchi <[hidden email]> wrote: This behavior is quite similar to what I am getting on my Mac laptop, |
Free forum by Nabble | Edit this page |