Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
30
Task/Empty-directory/Batch-File/empty-directory.bat
Normal file
30
Task/Empty-directory/Batch-File/empty-directory.bat
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
@echo off
|
||||
if "%~1"=="" exit /b 3
|
||||
set "samp_path=%~1"
|
||||
set "tst_var="
|
||||
|
||||
%== Store the current directory of the CMD ==%
|
||||
for /f %%T in ('cd') do set curr_dir=%%T
|
||||
|
||||
%== Go to the samp_path ==%
|
||||
cd %samp_path% 2>nul ||goto :folder_not_found
|
||||
|
||||
%== The current directory is now samp_path ==%
|
||||
%== Scan what is inside samp_path ==%
|
||||
for /f "usebackq delims=" %%D in (
|
||||
`dir /b 2^>nul ^& dir /b /ah 2^>nul`
|
||||
) do set "tst_var=1"
|
||||
|
||||
if "%tst_var%"=="1" (
|
||||
echo "%samp_path%" is NOT empty.
|
||||
cd %curr_dir%
|
||||
exit /b 1
|
||||
) else (
|
||||
echo "%samp_path%" is empty.
|
||||
cd %curr_dir%
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
:folder_not_found
|
||||
echo Folder not found.
|
||||
exit /b 2
|
||||
16
Task/Empty-directory/C++/empty-directory.cpp
Normal file
16
Task/Empty-directory/C++/empty-directory.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
path p(argv[i]);
|
||||
|
||||
if (exists(p) && is_directory(p))
|
||||
std::cout << "'" << argv[i] << "' is" << (!is_empty(p) ? " not" : "") << " empty\n";
|
||||
else
|
||||
std::cout << "dir '" << argv[i] << "' could not be found\n";
|
||||
}
|
||||
}
|
||||
2
Task/Empty-directory/Elixir/empty-directory.elixir
Normal file
2
Task/Empty-directory/Elixir/empty-directory.elixir
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
path = hd(System.argv)
|
||||
IO.puts File.dir?(path) and Enum.empty?( File.ls!(path) )
|
||||
3
Task/Empty-directory/NewLISP/empty-directory.newlisp
Normal file
3
Task/Empty-directory/NewLISP/empty-directory.newlisp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(define (empty-dir? path-to-check)
|
||||
(empty? (clean (lambda (x) (or (= "." x) (= ".." x))) (directory path-to-check)))
|
||||
)
|
||||
6
Task/Empty-directory/PowerShell/empty-directory.psh
Normal file
6
Task/Empty-directory/PowerShell/empty-directory.psh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
$path = "C:\Users"
|
||||
if((Dir $path).Count -eq 0) {
|
||||
"$path is empty"
|
||||
} else {
|
||||
"$path is not empty"
|
||||
}
|
||||
12
Task/Empty-directory/VBScript/empty-directory.vb
Normal file
12
Task/Empty-directory/VBScript/empty-directory.vb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Function IsDirEmpty(path)
|
||||
IsDirEmpty = False
|
||||
Set objFSO = CreateObject("Scripting.FileSystemObject")
|
||||
Set objFolder = objFSO.GetFolder(path)
|
||||
If objFolder.Files.Count = 0 And objFolder.SubFolders.Count = 0 Then
|
||||
IsDirEmpty = True
|
||||
End If
|
||||
End Function
|
||||
|
||||
'Test
|
||||
WScript.StdOut.WriteLine IsDirEmpty("C:\Temp")
|
||||
WScript.StdOut.WriteLine IsDirEmpty("C:\Temp\test")
|
||||
Loading…
Add table
Add a link
Reference in a new issue