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
YGOPRO-520DIY
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
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#define FILESYSTEM_H
#include <
string.h
>
#include <
cstdio
>
#include <functional>
#include <functional>
#include "bufferio.h"
#include "bufferio.h"
...
@@ -14,14 +14,13 @@
...
@@ -14,14 +14,13 @@
#ifdef _WIN32
#ifdef _WIN32
#include <wchar.h>
#define NOMINMAX
#define NOMINMAX
#include <Windows.h>
#include <Windows.h>
class
FileSystem
{
class
FileSystem
{
public:
public:
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
while
((
wfile
=
wcspbrk
(
wfile
,
L"<>:
\"
/
\\
|?*"
))
!=
NULL
)
while
((
wfile
=
std
::
wcspbrk
(
wfile
,
L"<>:
\"
/
\\
|?*"
))
!=
nullptr
)
*
wfile
++
=
'_'
;
*
wfile
++
=
'_'
;
}
}
...
@@ -71,8 +70,8 @@ public:
...
@@ -71,8 +70,8 @@ public:
static
bool
DeleteDir
(
const
wchar_t
*
wdir
)
{
static
bool
DeleteDir
(
const
wchar_t
*
wdir
)
{
wchar_t
pdir
[
256
];
wchar_t
pdir
[
256
];
BufferIO
::
CopyWideString
(
wdir
,
pdir
);
int
len
=
BufferIO
::
CopyWStr
(
wdir
,
pdir
,
sizeof
pdir
/
sizeof
pdir
[
0
]
);
pdir
[
wcslen
(
wdir
)
+
1
]
=
0
;
pdir
[
len
+
1
]
=
0
;
SHFILEOPSTRUCTW
lpFileOp
;
SHFILEOPSTRUCTW
lpFileOp
;
lpFileOp
.
hwnd
=
NULL
;
lpFileOp
.
hwnd
=
NULL
;
lpFileOp
.
wFunc
=
FO_DELETE
;
lpFileOp
.
wFunc
=
FO_DELETE
;
...
@@ -90,7 +89,7 @@ public:
...
@@ -90,7 +89,7 @@ public:
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
static
void
TraversalDir
(
const
wchar_t
*
wpath
,
const
std
::
function
<
void
(
const
wchar_t
*
,
bool
)
>&
cb
)
{
wchar_t
findstr
[
1024
];
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
;
WIN32_FIND_DATAW
fdataw
;
HANDLE
fh
=
FindFirstFileW
(
findstr
,
&
fdataw
);
HANDLE
fh
=
FindFirstFileW
(
findstr
,
&
fdataw
);
if
(
fh
==
INVALID_HANDLE_VALUE
)
if
(
fh
==
INVALID_HANDLE_VALUE
)
...
@@ -118,7 +117,7 @@ public:
...
@@ -118,7 +117,7 @@ public:
class
FileSystem
{
class
FileSystem
{
public:
public:
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
static
void
SafeFileName
(
wchar_t
*
wfile
)
{
while
((
wfile
=
wcspbrk
(
wfile
,
L"/"
))
!=
NULL
)
while
((
wfile
=
std
::
wcspbrk
(
wfile
,
L"/"
))
!=
nullptr
)
*
wfile
++
=
'_'
;
*
wfile
++
=
'_'
;
}
}
...
@@ -208,9 +207,7 @@ public:
...
@@ -208,9 +207,7 @@ public:
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
file_unit
funit
;
file_unit
funit
;
char
fname
[
1024
];
char
fname
[
1024
];
strcpy
(
fname
,
path
);
std
::
snprintf
(
fname
,
sizeof
fname
,
"%s/%s"
,
path
,
dirp
->
d_name
);
strcat
(
fname
,
"/"
);
strcat
(
fname
,
dirp
->
d_name
);
stat
(
fname
,
&
fileStat
);
stat
(
fname
,
&
fileStat
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
filename
=
std
::
string
(
dirp
->
d_name
);
funit
.
is_dir
=
S_ISDIR
(
fileStat
.
st_mode
);
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