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
508ba227
Commit
508ba227
authored
May 31, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/ArchiveLookup: use class FileInfo
parent
fa13648f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
ArchiveLookup.cxx
src/archive/ArchiveLookup.cxx
+9
-10
No files found.
src/archive/ArchiveLookup.cxx
View file @
508ba227
...
@@ -20,11 +20,10 @@
...
@@ -20,11 +20,10 @@
#include "ArchiveLookup.hxx"
#include "ArchiveLookup.hxx"
#include "ArchiveDomain.hxx"
#include "ArchiveDomain.hxx"
#include "Log.hxx"
#include "Log.hxx"
#include "fs/FileInfo.hxx"
#include "system/Error.hxx"
#include "system/Error.hxx"
#include <string.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
gcc_pure
gcc_pure
static
char
*
static
char
*
...
@@ -58,19 +57,16 @@ archive_lookup(char *pathname, const char **archive,
...
@@ -58,19 +57,16 @@ archive_lookup(char *pathname, const char **archive,
char
*
slash
=
nullptr
;
char
*
slash
=
nullptr
;
while
(
true
)
{
while
(
true
)
{
//try to stat if its real directory
try
{
struct
stat
st_info
;
//try to stat if its real directory
if
(
stat
(
pathname
,
&
st_info
)
==
-
1
)
{
const
FileInfo
file_info
(
Path
::
FromFS
(
pathname
));
int
e
=
errno
;
if
(
e
!=
ENOTDIR
)
throw
FormatErrno
(
e
,
"Failed to stat %s"
,
pathname
);
}
else
{
//is something found ins original path (is not an archive)
//is something found ins original path (is not an archive)
if
(
slash
==
nullptr
)
if
(
slash
==
nullptr
)
return
false
;
return
false
;
//its a file ?
//its a file ?
if
(
S_ISREG
(
st_info
.
st_mode
))
{
if
(
file_info
.
IsRegular
(
))
{
//so the upper should be file
//so the upper should be file
*
archive
=
pathname
;
*
archive
=
pathname
;
*
inpath
=
slash
+
1
;
*
inpath
=
slash
+
1
;
...
@@ -84,6 +80,9 @@ archive_lookup(char *pathname, const char **archive,
...
@@ -84,6 +80,9 @@ archive_lookup(char *pathname, const char **archive,
pathname
);
pathname
);
return
false
;
return
false
;
}
}
}
catch
(
const
std
::
system_error
&
e
)
{
if
(
!
IsPathNotFound
(
e
))
throw
;
}
}
//find one dir up
//find one dir up
...
...
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