include "NSLog.incl" local fn DirectoryContents( url as CFURLRef ) as CFArrayRef CFArrayRef contents = fn FileManagerContentsOfDirectoryAtURL( url, NULL, NSDirectoryEnumerationSkipsHiddenFiles ) if ( contents == NULL ) NSLog(@"Unable to get contents of directory \"%@\".",fn URLLastPathComponent(url)) end if end fn = fn ArrayValueForKey( contents, @"lastPathComponent" ) void local fn DoIt CFURLRef dirURL, fileURL CFArrayRef contents dirURL = fn URLFileURLWithPath( fn StringByExpandingTildeInPath( @"~/Desktop/docs" ) ) if ( fn FileManagerCreateDirectoryAtURL( dirURL, YES, NULL ) ) contents = fn DirectoryContents( dirURL ) if ( contents ) NSLog(@"Directory \"docs\" \b") if ( len(contents) ) NSLog(@"contents:\n%@",contents) else NSLog(@"is empty.") end if NSLog(@"") fileURL = fn URLFileURLWithPath( fn StringByExpandingTildeInPath( @"~/Desktop/docs/output.txt" ) ) if (fn FileManagerCreateFileAtURL( fileURL, NULL, NULL ) ) contents = fn DirectoryContents( dirURL ) NSLog(@"Directory \"docs\" \b") if ( len(contents) ) NSLog(@"contents:\n%@",contents) else NSLog(@"is empty.") end if end if end if end if end fn fn DoIt HandleEvents