June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
2
Task/Empty-directory/Factor/empty-directory.factor
Normal file
2
Task/Empty-directory/Factor/empty-directory.factor
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
USE: io.directories
|
||||
: empty-directory? ( path -- ? ) directory-entries empty? ;
|
||||
20
Task/Empty-directory/Rust/empty-directory.rust
Normal file
20
Task/Empty-directory/Rust/empty-directory.rust
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use std::fs::read_dir;
|
||||
use std::error::Error;
|
||||
|
||||
fn main() {
|
||||
for path in std::env::args().skip(1) { // iterate over the arguments, skipping the first (which is the executable)
|
||||
match read_dir(path.as_str()) { // try to read the directory specified
|
||||
Ok(contents) => {
|
||||
let len = contents.collect::<Vec<_>>().len(); // calculate the amount of items in the directory
|
||||
if len == 0 {
|
||||
println!("{} is empty", path);
|
||||
} else {
|
||||
println!("{} is not empty", path);
|
||||
}
|
||||
},
|
||||
Err(e) => { // If the attempt failed, print the corresponding error msg
|
||||
println!("Failed to read directory \"{}\": {}", path, e.description());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Task/Empty-directory/VBA/empty-directory.vba
Normal file
11
Task/Empty-directory/VBA/empty-directory.vba
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Sub Main()
|
||||
Debug.Print IsEmptyDirectory("C:\Temp")
|
||||
Debug.Print IsEmptyDirectory("C:\Temp\")
|
||||
End Sub
|
||||
|
||||
Private Function IsEmptyDirectory(D As String) As Boolean
|
||||
Dim Sep As String
|
||||
Sep = Application.PathSeparator
|
||||
D = IIf(Right(D, 1) <> Sep, D & Sep, D)
|
||||
IsEmptyDirectory = (Dir(D & "*.*") = "")
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue