Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
969dbe4b
Commit
969dbe4b
authored
Oct 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
90301a73
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+14
-6
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+9
-0
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
969dbe4b
...
...
@@ -31,12 +31,19 @@ using namespace golang;
#include <memory>
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
);
// io::
namespace
io
{
const
error
EOF_
=
fmt
::
errorf
(
"EOF"
);
}
// io::
// os::
namespace
os
{
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
);
tuple
<
File
,
error
>
open
(
const
string
&
path
,
int
flags
,
mode_t
mode
)
{
File
f
;
f
.
_path
=
path
;
...
...
@@ -63,7 +70,7 @@ tuple<int, error> File::read(void *buf, size_t count) {
n
=
::
read
(
f
->
_fd
,
buf
,
count
);
if
(
n
==
0
)
return
make_tuple
(
n
,
io
::
EOF
);
return
make_tuple
(
n
,
io
::
EOF
_
);
if
(
n
<
0
)
return
make_tuple
(
0
,
f
->
_errno
(
"read"
));
...
...
@@ -81,7 +88,7 @@ tuple <int, error> File::write(const void *buf, size_t count) {
return
make_tuple
(
wrote
,
f
->
_errno
(
"write"
));
wrote
+=
n
;
buf
+=
n
;
buf
=
((
const
char
*
)
buf
)
+
n
;
count
-=
n
;
}
...
...
@@ -104,8 +111,6 @@ error File::_errno(const char *op) {
return
_pathError
(
op
,
f
->
_path
,
errno
);
}
}
// os::
// _pathError returns os.PathError-like for op/path and system error
// indicated by syserr.
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
)
{
...
...
@@ -114,6 +119,9 @@ static error _pathError(const char *op, const string &path, int syserr) {
return
fmt
::
errorf
(
"%s %s: %s"
,
op
,
path
.
c_str
(),
estr
);
}
}
// os::
// mm::
namespace
mm
{
...
...
@@ -125,7 +133,7 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File &f,
addr2
=
mmap
(
addr
,
size
,
prot
,
MAP_FIXED
|
flags
,
f
.
fd
(),
offset
);
if
(
addr2
==
MAP_FAILED
)
return
_pathError
(
"mmap"
,
f
.
name
(),
errno
);
return
os
::
_pathError
(
"mmap"
,
f
.
name
(),
errno
);
if
(
addr2
!=
addr
)
panic
(
"mmap(addr, MAP_FIXED): returned !addr"
);
return
nil
;
...
...
wcfs/internal/wcfs_misc.h
View file @
969dbe4b
...
...
@@ -47,6 +47,15 @@ struct error {
}
};
// io::
namespace
io
{
extern
const
error
EOF_
;
}
// io::
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
...
...
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