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
a5760670
Commit
a5760670
authored
Mar 03, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/io/FileReader: add method GetFileInfo()
parent
f04a3ec2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletion
+26
-1
FileInfo.hxx
src/fs/FileInfo.hxx
+1
-0
FileReader.cxx
src/fs/io/FileReader.cxx
+22
-1
FileReader.hxx
src/fs/io/FileReader.hxx
+3
-0
No files found.
src/fs/FileInfo.hxx
View file @
a5760670
...
...
@@ -54,6 +54,7 @@ class FileInfo {
bool
follow_symlinks
);
friend
bool
GetFileInfo
(
Path
path
,
FileInfo
&
info
,
Error
&
error
);
friend
class
FileReader
;
#ifdef WIN32
WIN32_FILE_ATTRIBUTE_DATA
data
;
...
...
src/fs/io/FileReader.cxx
View file @
a5760670
...
...
@@ -19,7 +19,7 @@
#include "config.h"
#include "FileReader.hxx"
#include "fs/File
System
.hxx"
#include "fs/File
Info
.hxx"
#include "util/Error.hxx"
#ifdef WIN32
...
...
@@ -36,6 +36,14 @@ FileReader::FileReader(Path _path, Error &error)
}
}
bool
FileReader
::
GetFileInfo
(
FileInfo
&
info
,
Error
&
error
)
const
{
assert
(
IsDefined
());
return
::
GetFileInfo
(
path
,
info
,
error
);
}
size_t
FileReader
::
Read
(
void
*
data
,
size_t
size
,
Error
&
error
)
{
...
...
@@ -83,6 +91,19 @@ FileReader::FileReader(Path _path, Error &error)
error
.
FormatErrno
(
"Failed to open %s"
,
path
.
c_str
());
}
bool
FileReader
::
GetFileInfo
(
FileInfo
&
info
,
Error
&
error
)
const
{
assert
(
IsDefined
());
const
bool
success
=
fstat
(
fd
.
Get
(),
&
info
.
st
)
==
0
;
if
(
!
success
)
error
.
FormatErrno
(
"Failed to access %s"
,
path
.
ToUTF8
().
c_str
());
return
success
;
}
size_t
FileReader
::
Read
(
void
*
data
,
size_t
size
,
Error
&
error
)
{
...
...
src/fs/io/FileReader.hxx
View file @
a5760670
...
...
@@ -36,6 +36,7 @@
#endif
class
Path
;
class
FileInfo
;
class
FileReader
final
:
public
Reader
{
AllocatedPath
path
;
...
...
@@ -79,6 +80,8 @@ public:
void
Close
();
bool
GetFileInfo
(
FileInfo
&
info
,
Error
&
error
)
const
;
bool
Seek
(
off_t
offset
,
Error
&
error
);
/* virtual methods from class Reader */
...
...
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