-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdir.src
110 lines (95 loc) · 1.74 KB
/
dir.src
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# dir.src
# Test of Directory System Functions
# $Id: dir.src,v 1.3 2000/10/26 11:36:52 rswindell Exp $
# @format.tab-size 8, @format.use-tabs true
!include sbbsdefs.inc
!include dir_attr.inc
int dir fattr flen ftime bytes files i
str path name attr time date
print "Directory of: "
getstrupr path 60
open_dir dir path
if_false
printf "Unable to open %s\r\n" path
return
end_if
printf "Directory of %s\r\n\r\n" path
:next
copy i _sys_status
and i SS_ABORT
compare i 0
if_not_equal # Ctrl-C hit
print "Aborted.\n"
goto end
end_if
read_dir dir name
if_false
goto end
end_if
# Increment file counter
add files 1
sprintf str "%s\\%s" path name
get_file_attrib fattr str
get_file_length flen str
# Add to total byte counter
compare flen 0
if_greater
add bytes flen
end_if
get_file_time ftime str
ftime_str time "%H:%M:%S" ftime
ftime_str date "%m/%d/%y" ftime
set attr ""
copy i fattr
and i FA_RDONLY
compare i 0
if_not_equal
strcat attr "r"
else
strcat attr "-"
end_if
copy i fattr
and i FA_HIDDEN
compare i 0
if_not_equal
strcat attr "h"
else
strcat attr "-"
end_if
copy i fattr
and i FA_SYSTEM
compare i 0
if_not_equal
strcat attr "s"
else
strcat attr "-"
end_if
copy i fattr
and i FA_LABEL
compare i 0
if_not_equal
strcat attr "l"
else
strcat attr "-"
end_if
copy i fattr
and i FA_DIREC
compare i 0
if_not_equal
strcat attr "d"
else
strcat attr "-"
end_if
copy i fattr
and i FA_ARCH
compare i 0
if_not_equal
strcat attr "a"
else
strcat attr "-"
end_if
printf "%s %10ld %s %s %s\r\n" attr flen date time name
goto next
:end
close_dir dir
printf "\r\n%lu total bytes in %lu files\r\n" bytes files