How to determine if a file is hidden

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

How to determine if a file is hidden

Rob Rothwell
Hello,

Is there a way to determine if a file is hidden?  I couldn't find that in "Deep into Pharo".

For example, I can get my desktop files with:

desktopFiles := FileLocator desktop children.

And now I would like to filter that collection to the non-hiddent files with something like:

desktopFiles select: [:each | each isHidden not ]

But there doesn't seem to be anything like "isHidden" for a FileLocator object.

Thank you,

Rob Rothwell

Reply | Threaded
Open this post in threaded view
|

Re: How to determine if a file is hidden

Damien Pollet-2
Hidden in what sense?

On Linux, files whose name start with a period are "hidden" (by convention, many commands ignore them)

On OS X, files and directories that are hidden to the Finder have a special attribute in the file system. I don't think there's an accessor for that in Pharo yet, but as a workaround you can use the system command GetFileInfo to check the state of the invisibility flag (v):

GetFileInfo -a v /Applications
# should echo 0 (invisibility flag not set)

GetFileInfo -a v /bin
# should echo 1


On 9 April 2016 at 21:12, Robert J Rothwell <[hidden email]> wrote:
Hello,

Is there a way to determine if a file is hidden?  I couldn't find that in "Deep into Pharo".

For example, I can get my desktop files with:

desktopFiles := FileLocator desktop children.

And now I would like to filter that collection to the non-hiddent files with something like:

desktopFiles select: [:each | each isHidden not ]

But there doesn't seem to be anything like "isHidden" for a FileLocator object.

Thank you,

Rob Rothwell


Reply | Threaded
Open this post in threaded view
|

Re: How to determine if a file is hidden

Rob Rothwell
Thanks Damien,

I'm sorry...yes visibility is exactly what I meant, and on a Mac as well.

You are right that some invisible things start with a period (on a Mac as well, so that's easy), and others have the invisibility flag set.  Should I be able to use OSWindows to use getfileinfo from within pharo?  I haven't been able to figure it out yet, and am kind of "starting from scratch" with Pharo (again) because I haven't tried it out for a long time (for various reasons).

However, I have recently been inspired by how I have to work with Windows at work (I use Parallels). I decided to look at Pharo with fresh eyes as just another OS that could do different things in the same way that I do some things only in Windows (my company provides a Windows-based object database platform for data quality written in VisualWorks).  This paradigm shift has suddenly freed me from "I want to write Cocoa apps in Pharo" mode.

I manage all my projects in a simple file-based manner so I can easily switch back and forth (between Mac and Windows) as needed, and take advantage of the Parallels features to "Open in Windows," or "Open on Mac,"  as well as Desktop sharing.

I thought it would be an interesting exercise to try to create a way to work with files and folders in a similar fashion in Pharo (shared desktop, better file browsing, etc...), and my first sticking point was "what if I don't want to see all these [invisible] files."

I'm hoping I might be able to learn Spec that way, as well as communicating with the image to provide a similar "Open in Pharo" service (for pharo application files I might invent), and of course I need to know how to interact with the Mac OS as well, so this seemed like a nice, small place to start.

Thanks again for your help,

Rob

On Apr 9, 2016, at 4:51 PM, Damien Pollet <[hidden email]> wrote:

Hidden in what sense?

On Linux, files whose name start with a period are "hidden" (by convention, many commands ignore them)

On OS X, files and directories that are hidden to the Finder have a special attribute in the file system. I don't think there's an accessor for that in Pharo yet, but as a workaround you can use the system command GetFileInfo to check the state of the invisibility flag (v):

GetFileInfo -a v /Applications
# should echo 0 (invisibility flag not set)

GetFileInfo -a v /bin
# should echo 1


On 9 April 2016 at 21:12, Robert J Rothwell <[hidden email]> wrote:
Hello,

Is there a way to determine if a file is hidden?  I couldn't find that in "Deep into Pharo".

For example, I can get my desktop files with:

desktopFiles := FileLocator desktop children.

And now I would like to filter that collection to the non-hiddent files with something like:

desktopFiles select: [:each | each isHidden not ]

But there doesn't seem to be anything like "isHidden" for a FileLocator object.

Thank you,

Rob Rothwell



Reply | Threaded
Open this post in threaded view
|

Re: How to determine if a file is hidden

Damien Pollet-2

On 10 April 2016 at 00:13, Robert J Rothwell <[hidden email]> wrote:
Should I be able to use OSWindows to use getfileinfo from within pharo?

No, to run external programs, the package you want is OSSubProcess.