-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-directory.bm
More file actions
93 lines (92 loc) · 3.04 KB
/
Copy pathtest-directory.bm
File metadata and controls
93 lines (92 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'$INCLUDE:'.\ddlib\constants.bi'
'$INCLUDE:'.\ddlib\library.bm'
'$INCLUDE:'.\test-print.bm'
' ----------------------------------------------------------------------------
function test.GetTestFolder$()
test.GetTestFolder$ = "c:\temp\dirtestfolder"
end function
' ----------------------------------------------------------------------------
sub test.Directory
call test.Exists
call test.Delete
call test.CreateDirectory
call test.GetFiles
call test.GetFolders
call test.Search
end sub
' ----------------------------------------------------------------------------
sub test.Exists
if instr(_os$,"[WINDOWS]") > 0 then
if directory.Exists("c:\windows") then
print.success("directory.Exists")
else
print.fail("directory.Exists")
end if
end if
end sub
' ----------------------------------------------------------------------------
sub test.Delete
call directory.Delete(test.GetTestFolder$)
if directory.Exists(test.GetTestFolder$) then
print.fail("directory.Delete")
else
print.success("directory.Delete")
end if
end sub
' ----------------------------------------------------------------------------
sub test.CreateDirectory
if directory.CreateDirectory(test.GetTestFolder$) then
print.success("directory.CreateDirectory")
else
print.fail("directory.CreateDirectory")
end if
end sub
' ----------------------------------------------------------------------------
sub test.GetFiles
dim filelist(1 to 0) as string
dim searchFolder as string : searchFolder = path.AddSlash(_cwd$) + "testdata"
call directory.GetFiles(searchFolder, filelist(), boolean.FALSE)
if ubound(filelist) <> 4 then
print.fail("directory.GetAllFiles")
else
call directory.GetFiles(searchFolder, filelist(), boolean.TRUE)
if ubound(filelist) <> 8 then
print.fail("directory.GetAllFiles /s")
else
print.success("directory.GetAllFiles")
end if
end if
end sub
' ----------------------------------------------------------------------------
sub test.GetFolders
dim filelist(1 to 0) as string
dim searchFolder as string : searchFolder = path.AddSlash(_cwd$) + "testdata"
call directory.GetFolders(searchFolder, filelist(), boolean.FALSE)
if ubound(filelist) = 2 then
call directory.GetFolders(searchFolder, filelist(), boolean.TRUE)
if ubound(filelist) <> 3 then
print.fail("directory.GetFolders /s")
else
print.success("directory.GetFolders")
end if
else
print.fail("directory.GetFolders")
end if
end sub
' ----------------------------------------------------------------------------
sub test.Search
dim filelist(1 to 0) as string
dim searchCommand as string : searchCommand = "dir " + path.AddSlash(_cwd$) + "testdata\f1.txt /b"
call directory.Search(searchCommand, filelist())
if ubound(filelist) <> 1 then
print.fail("directory.Search - '" + searchCommand + "'")
else
searchCommand = "dir " + path.AddSlash(_cwd$) + "testdata\f1.txt /b/s"
call directory.Search(searchCommand, filelist())
if ubound(filelist) <> 4 then
call print.fail("directory.Search - '" + searchCommand + "'")
else
call print.success("directory.Search")
end if
end if
end sub