[mac?] Meta_File:exists -- RawPointer or nil

View: New views
2 Messages — Rating Filter:   Alert me  

[mac?] Meta_File:exists -- RawPointer or nil

by Stephan Wittwer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

Can someone explain this?
2 files created, one in cwd, the other in user app support dir.
The latter is not recognized by Meta_File:exists.

Grateful for any hint !
Stephan



(
~p1 = "testfile";
        // escape space char (mac path)
~p2 = Platform.userAppSupportDir.escapeChar($ ) +/+ ~p1;
        // create two empty files
("touch" + ~p1 + ~p2).systemCmd;
)

        // line by line
File.exists(~p1); // true
File.exists(~p2); // false

~p1.pathMatch;
~p2.pathMatch; // showing up here

        // the difference:
File.use(~p1, "r", { |f| f.dump }); // fileptr : RawPointer ...
File.use(~p2, "r", { |f| f.dump }); // fileptr : nil

        // permissions look the same (to me)
("ls -l " ++ ~p1.dirname).unixCmd;
("ls -l " ++ ~p2.dirname).unixCmd;



        // clean up
("rm" + ~p1 + ~p2).systemCmd

_______________________________________________
sc-users mailing list

sc-users@...
archive: http://www.listarc.bham.ac.uk/lists/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Re: [mac?] Meta_File:exists -- RawPointer or nil

by Stephan Wittwer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


To answer my own question:

> Hi list,
>
> Can someone explain this?
> 2 files created, one in cwd, the other in user app support dir.
> The latter is not recognized by Meta_File:exists.


The problem was escaping the blank in the path name.

File class doesn't like

Platform.userAppSupportDir.escapeChar($ )

wheras unixCmd et al need the escaping (for the Mac path name) and,  
third variant, pathMatch doesn't care if the space char is escaped or  
not.


Although it appears slightly cumbersome to me to need different string  
versions for the same path in a different context, I'm still happy  
now, having found an explanation.




>
>
>
> (
> ~p1 = "testfile";
> // escape space char (mac path)
> ~p2 = Platform.userAppSupportDir.escapeChar($ ) +/+ ~p1;
> // create two empty files
> ("touch" + ~p1 + ~p2).systemCmd;
> )
>
> // line by line
> File.exists(~p1); // true
> File.exists(~p2); // false
>
> ~p1.pathMatch;
> ~p2.pathMatch; // showing up here
>
> // the difference:
> File.use(~p1, "r", { |f| f.dump }); // fileptr : RawPointer ...
> File.use(~p2, "r", { |f| f.dump }); // fileptr : nil
>
> // permissions look the same (to me)
> ("ls -l " ++ ~p1.dirname).unixCmd;
> ("ls -l " ++ ~p2.dirname).unixCmd;
>
>
>
> // clean up
> ("rm" + ~p1 + ~p2).systemCmd
>

_______________________________________________
sc-users mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
LightInTheBox - Buy quality products at wholesale price