Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6b3b1cbd
Commit
6b3b1cbd
authored
Feb 27, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/FileSystem: use GetFileAttributes() on WIN32 if possible
parent
4dd861ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
FileSystem.hxx
src/fs/FileSystem.hxx
+20
-2
No files found.
src/fs/FileSystem.hxx
View file @
6b3b1cbd
...
...
@@ -26,10 +26,15 @@
#include "Path.hxx"
#ifdef WIN32
#include <fileapi.h>
#endif
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
class
AllocatedPath
;
namespace
FOpenMode
{
...
...
@@ -128,8 +133,15 @@ CheckAccess(Path path, int mode)
static
inline
bool
FileExists
(
Path
path
,
bool
follow_symlinks
=
true
)
{
#ifdef WIN32
(
void
)
follow_symlinks
;
const
auto
a
=
GetFileAttributes
(
path
.
c_str
());
return
a
!=
INVALID_FILE_ATTRIBUTES
&&
(
a
&
FILE_ATTRIBUTE_NORMAL
);
#else
struct
stat
buf
;
return
StatFile
(
path
,
buf
,
follow_symlinks
)
&&
S_ISREG
(
buf
.
st_mode
);
#endif
}
/**
...
...
@@ -138,8 +150,15 @@ FileExists(Path path, bool follow_symlinks = true)
static
inline
bool
DirectoryExists
(
Path
path
,
bool
follow_symlinks
=
true
)
{
#ifdef WIN32
(
void
)
follow_symlinks
;
const
auto
a
=
GetFileAttributes
(
path
.
c_str
());
return
a
!=
INVALID_FILE_ATTRIBUTES
&&
(
a
&
FILE_ATTRIBUTE_DIRECTORY
);
#else
struct
stat
buf
;
return
StatFile
(
path
,
buf
,
follow_symlinks
)
&&
S_ISDIR
(
buf
.
st_mode
);
#endif
}
/**
...
...
@@ -149,8 +168,7 @@ static inline bool
PathExists
(
Path
path
)
{
#ifdef WIN32
struct
stat
buf
;
return
StatFile
(
path
,
buf
);
return
GetFileAttributes
(
path
.
c_str
())
!=
INVALID_FILE_ATTRIBUTES
;
#else
return
CheckAccess
(
path
,
F_OK
);
#endif
...
...
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