Wondering if fileExistsAtPath works with ASObj-C

Shane or Mark,

I found an NSFileManager’s defaultManager()'s call of the method fileExistsAtPath online where the person claimed this worked. As I understand it defaultManager() just returns the FileManger’s default setup. So there is nothing mysterious about that. The problem is when I use the script below it returns the number one, which equates to true, for the second output when using fileExistsAtPath. Both the PathToFile and PathToDirectory return true. I used “reference” instead of “missing value” to get the second output value.

Both the file and directory exists.

Am I missing something here or does PathToFile not work?

set PathToFile to "/Users/bill/Desktop/Dialog Toolkit.scptd"
set PathToDirectory to "/Users/bill/Desktop/Folder_344"
set {ObjectExists1, IsADirectory1} to current application's NSFileManager's defaultManager()'s fileExistsAtPath:PathToFile isDirectory:(reference)
set {ObjectExists2, IsADirectory2} to current application's NSFileManager's defaultManager()'s fileExistsAtPath:PathToDirectory isDirectory:(reference)

return {ObjectExists1, IsADirectory1, ObjectExists2, IsADirectory2} -- This evaluates to {true, 1, true, 1} which means both exist & both are directories

Bill

1 Like

That’s correct. A .scptd file is a package, which is a directory even if it doesn’t look like one.

Thanks Shane : ) For some reason I was thinking I was thinking isDirectory would work like Finder. But NSFileManager is lower level then Finder.