Empty directory: Difference between revisions

no edit summary
m (syntax highlighting fixup automation)
No edit summary
Line 540:
<pre>
'c:\freebasic\docs' is empty
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
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
</syntaxhighlight>
 
{{out}}
<pre>
Directory "docs" is empty.
 
Directory "docs" contents:
(
"output.txt"
)
</pre>
 
416

edits