Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
cd8e80aa
Commit
cd8e80aa
authored
Aug 26, 2017
by
rswindell
Browse files
Added getfilecount(), similar, but not identical to getdirsize().
parent
53f8e5ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
src/xpdev/dirwrap.c
src/xpdev/dirwrap.c
+29
-0
src/xpdev/dirwrap.h
src/xpdev/dirwrap.h
+1
-0
No files found.
src/xpdev/dirwrap.c
View file @
cd8e80aa
...
...
@@ -300,6 +300,10 @@ void DLLCALL globfree(glob_t* glob)
#endif
/* !defined(__unix__) */
/****************************************************************************/
/* Returns number of files and/or sub-directories in directory (path) */
/* Similar, but not identical, to getfilecount() */
/****************************************************************************/
long
DLLCALL
getdirsize
(
const
char
*
path
,
BOOL
include_subdirs
,
BOOL
subdir_only
)
{
char
match
[
MAX_PATH
+
1
];
...
...
@@ -735,6 +739,31 @@ ulong DLLCALL delfiles(const char *inpath, const char *spec)
return
(
files
);
}
/****************************************************************************/
/* Returns number of files in a directory (inpath) matching 'pattern' */
/* Similar, but not identical, to getdirsize(), e.g. subdirs never counted */
/****************************************************************************/
ulong
DLLCALL
getfilecount
(
const
char
*
inpath
,
const
char
*
pattern
)
{
char
path
[
MAX_PATH
+
1
];
glob_t
g
;
uint
gi
;
ulong
count
=
0
;
SAFECOPY
(
path
,
inpath
);
backslash
(
path
);
strcat
(
path
,
pattern
);
if
(
glob
(
path
,
GLOB_MARK
,
NULL
,
&
g
))
return
0
;
for
(
gi
=
0
;
gi
<
g
.
gl_pathc
;
++
gi
)
{
if
(
*
lastchar
(
g
.
gl_pathv
[
gi
])
==
'/'
)
continue
;
count
++
;
}
globfree
(
&
g
);
return
count
;
}
/****************************************************************************/
/* Return free disk space in bytes (up to a maximum of 4GB) */
/****************************************************************************/
...
...
src/xpdev/dirwrap.h
View file @
cd8e80aa
...
...
@@ -227,6 +227,7 @@ DLLEXPORT BOOL DLLCALL isfullpath(const char* filename);
DLLEXPORT
char
*
DLLCALL
getfname
(
const
char
*
path
);
DLLEXPORT
char
*
DLLCALL
getfext
(
const
char
*
path
);
DLLEXPORT
int
DLLCALL
getfattr
(
const
char
*
filename
);
DLLEXPORT
ulong
DLLCALL
getfilecount
(
const
char
*
inpath
,
const
char
*
spec
);
DLLEXPORT
long
DLLCALL
getdirsize
(
const
char
*
path
,
BOOL
include_subdirs
,
BOOL
subdir_only
);
DLLEXPORT
ulong
DLLCALL
getdisksize
(
const
char
*
path
,
ulong
unit
);
DLLEXPORT
ulong
DLLCALL
getfreediskspace
(
const
char
*
path
,
ulong
unit
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment