Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
25f6a16a
Commit
25f6a16a
authored
5 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
batch_file_remove() can now remove multiple files matching pattern
Returns count of files removed now (not bool).
parent
0c4e29c2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/filedat.c
+10
-3
10 additions, 3 deletions
src/sbbs3/filedat.c
src/sbbs3/filedat.h
+1
-1
1 addition, 1 deletion
src/sbbs3/filedat.h
with
11 additions
and
4 deletions
src/sbbs3/filedat.c
+
10
−
3
View file @
25f6a16a
...
...
@@ -448,17 +448,24 @@ size_t batch_file_count(scfg_t* cfg, uint usernumber, enum XFER_TYPE type)
return
result
;
}
bool
batch_file_remove
(
scfg_t
*
cfg
,
uint
usernumber
,
enum
XFER_TYPE
type
,
const
char
*
filename
)
int
batch_file_remove
(
scfg_t
*
cfg
,
uint
usernumber
,
enum
XFER_TYPE
type
,
const
char
*
filename
)
{
FILE
*
fp
=
batch_list_open
(
cfg
,
usernumber
,
type
,
/* for_modify: */
true
);
if
(
fp
==
NULL
)
return
false
;
str_list_t
ini
=
iniReadFile
(
fp
);
bool
result
=
iniRemoveSection
(
&
ini
,
filename
);
str_list_t
files
=
iniGetSectionList
(
ini
,
NULL
);
int
removed
=
0
;
for
(
int
n
=
0
;
files
[
n
]
!=
NULL
;
++
n
)
{
if
(
wildmatch
(
files
[
n
],
filename
,
/* path: */
false
,
/* case-sensitive: */
false
))
{
if
(
iniRemoveSection
(
&
ini
,
files
[
n
]))
++
removed
;
}
}
iniWriteFile
(
fp
,
ini
);
iniCloseFile
(
fp
);
iniFreeStringList
(
ini
);
return
re
sult
;
return
re
moved
;
}
// 'n' is zero-based index of file to remove
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/filedat.h
+
1
−
1
View file @
25f6a16a
...
...
@@ -88,7 +88,7 @@ DLLEXPORT bool batch_list_clear(scfg_t*, uint usernumber, enum XFER_TYPE);
DLLEXPORT
bool
batch_file_add
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
,
file_t
*
);
DLLEXPORT
bool
batch_file_exists
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
,
const
char
*
filename
);
DLLEXPORT
bool
batch_file_remove
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
,
const
char
*
filename
);
DLLEXPORT
int
batch_file_remove
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
,
const
char
*
filename
);
DLLEXPORT
bool
batch_file_remove_n
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
,
uint
n
);
DLLEXPORT
size_t
batch_file_count
(
scfg_t
*
,
uint
usernumber
,
enum
XFER_TYPE
);
DLLEXPORT
bool
batch_file_get
(
scfg_t
*
,
str_list_t
,
const
char
*
filename
,
file_t
*
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment