Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro
Commits
8385b896
Commit
8385b896
authored
Oct 12, 2024
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
myfilesystem: use std functions
parent
d536b9a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
gframe/myfilesystem.h
gframe/myfilesystem.h
+7
-10
No files found.
gframe/myfilesystem.h
View file @
8385b896
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <
string.h
>
#include <
cstdio
>
#include <functional>
#include "bufferio.h"
...
...
@@ -14,14 +14,13 @@
#ifdef _WIN32
#include <wchar.h>
#define NOMINMAX
#include <Windows.h>
class
FileSystem
{
public:
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
while
((
wfile
=
wcspbrk
(
wfile
,
L"<>:
\"
/
\\
|?*"
))
!=
NULL
)
while
((
wfile
=
std
::
wcspbrk
(
wfile
,
L"<>:
\"
/
\\
|?*"
))
!=
nullptr
)
*
wfile
++
=
'_'
;
}
...
...
@@ -71,8 +70,8 @@ public:
static
bool
DeleteDir
(
const
wchar_t
*
wdir
)
{
wchar_t
pdir
[
256
];
BufferIO
::
CopyWideString
(
wdir
,
pdir
);
pdir
[
wcslen
(
wdir
)
+
1
]
=
0
;
int
len
=
BufferIO
::
CopyWStr
(
wdir
,
pdir
,
sizeof
pdir
/
sizeof
pdir
[
0
]
);
pdir
[
len
+
1
]
=
0
;
SHFILEOPSTRUCTW
lpFileOp
;
lpFileOp
.
hwnd
=
NULL
;
lpFileOp
.
wFunc
=
FO_DELETE
;
...
...
@@ -90,7 +89,7 @@ public:
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
wchar_t
findstr
[
1024
];
s
wprintf
(
findstr
,
1024
,
L"%s/*"
,
wpath
);
s
td
::
swprintf
(
findstr
,
sizeof
findstr
/
sizeof
findstr
[
0
]
,
L"%s/*"
,
wpath
);
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
findstr
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
...
...
@@ -118,7 +117,7 @@ public:
class
FileSystem
{
public:
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
while
((
wfile
=
wcspbrk
(
wfile
,
L"/"
))
!=
NULL
)
while
((
wfile
=
std
::
wcspbrk
(
wfile
,
L"/"
))
!=
nullptr
)
*
wfile
++
=
'_'
;
}
...
...
@@ -208,9 +207,7 @@ public:
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
file_unit
funit
;
char
fname
[
1024
];
strcpy
(
fname
,
path
);
strcat
(
fname
,
"/"
);
strcat
(
fname
,
dirp
->
d_name
);
std
::
snprintf
(
fname
,
sizeof
fname
,
"%s/%s"
,
path
,
dirp
->
d_name
);
stat
(
fname
,
&
fileStat
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
is_dir
=
S_ISDIR
(
fileStat
.
st_mode
);
...
...
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