Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
6d4c05da
Commit
6d4c05da
authored
Oct 24, 2016
by
Kenton Varda
Committed by
Kenton Varda
Apr 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge OsHandle into FsNode.
parent
e3c4dd6f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
26 deletions
+19
-26
filesystem-disk.c++
c++/src/kj/filesystem-disk.c++
+1
-1
filesystem.c++
c++/src/kj/filesystem.c++
+3
-3
filesystem.h
c++/src/kj/filesystem.h
+15
-22
No files found.
c++/src/kj/filesystem-disk.c++
View file @
6d4c05da
...
...
@@ -1398,7 +1398,7 @@ protected:
#define FSNODE_METHODS(classname) \
Maybe<int> getFd() override { return DiskHandle::getFd(); } \
\
Own<
OsHandle> cloneOsHandle() override {
\
Own<
FsNode> cloneFsNode() override {
\
return heap<classname>(DiskHandle::clone()); \
} \
\
...
...
c++/src/kj/filesystem.c++
View file @
6d4c05da
...
...
@@ -704,7 +704,7 @@ class InMemoryFile final: public File, public Refcounted {
public
:
InMemoryFile
(
Clock
&
clock
)
:
clock
(
clock
),
lastModified
(
clock
.
now
())
{}
Own
<
OsHandle
>
cloneOsHandl
e
()
override
{
Own
<
FsNode
>
cloneFsNod
e
()
override
{
return
addRef
(
*
this
);
}
...
...
@@ -892,7 +892,7 @@ public:
InMemoryDirectory
(
Clock
&
clock
)
:
clock
(
clock
),
lastModified
(
clock
.
now
())
{}
Own
<
OsHandle
>
cloneOsHandl
e
()
override
{
Own
<
FsNode
>
cloneFsNod
e
()
override
{
return
addRef
(
*
this
);
}
...
...
@@ -1555,7 +1555,7 @@ class AppendableFileImpl final: public AppendableFile {
public
:
AppendableFileImpl
(
Own
<
File
>&&
fileParam
)
:
file
(
kj
::
mv
(
fileParam
))
{}
Own
<
OsHandle
>
cloneOsHandl
e
()
override
{
Own
<
FsNode
>
cloneFsNod
e
()
override
{
return
heap
<
AppendableFileImpl
>
(
file
->
clone
());
}
...
...
c++/src/kj/filesystem.h
View file @
6d4c05da
...
...
@@ -241,9 +241,11 @@ private:
// L1). You can't do asynchronous RAM access so why asynchronous filesystem? The only way to
// parallelize these is using threads.
class
OsHandle
{
class
FsNode
{
// Base class for filesystem node types.
public
:
Own
<
OsHandl
e
>
clone
();
Own
<
FsNod
e
>
clone
();
// Creates a new object of exactly the same type as this one, pointing at exactly the same
// external object.
//
...
...
@@ -252,19 +254,6 @@ public:
virtual
Maybe
<
int
>
getFd
()
=
0
;
// Get the underlying file descriptor, if any. Returns nullptr if this object actually isn't
// wrapping a file descriptor.
//
// TODO(now): Do we really want everything inheriting OsHandle or should people dynamic_cast to
// it? What about people without RTTI?
protected
:
virtual
Own
<
OsHandle
>
cloneOsHandle
()
=
0
;
// Implements clone(). Required to return an object with exactly the same type as this one.
// Hence, every subclass must implement this.
};
class
FsNode
:
public
OsHandle
{
public
:
Own
<
FsNode
>
clone
();
enum
class
Type
{
FILE
,
...
...
@@ -310,6 +299,11 @@ public:
// into the filesystem (*after* syncing the data), so than incomplete data is never visible to
// other processes. (In practice this works by writing into a temporary file and then rename()ing
// it.)
protected
:
virtual
Own
<
FsNode
>
cloneFsNode
()
=
0
;
// Implements clone(). Required to return an object with exactly the same type as this one.
// Hence, every subclass must implement this.
};
class
ReadableFile
:
public
FsNode
{
...
...
@@ -888,17 +882,16 @@ inline PathPtr PathPtr::slice(size_t start, size_t end) const {
return
PathPtr
(
parts
.
slice
(
start
,
end
));
}
inline
Own
<
OsHandle
>
OsHandle
::
clone
()
{
return
cloneOsHandle
();
}
inline
Own
<
FsNode
>
FsNode
::
clone
()
{
return
cloneOsHandle
().
downcast
<
FsNode
>
();
}
inline
Own
<
ReadableFile
>
ReadableFile
::
clone
()
{
return
cloneOsHandle
().
downcast
<
ReadableFile
>
();
}
inline
Own
<
FsNode
>
FsNode
::
clone
()
{
return
cloneFsNode
().
downcast
<
FsNode
>
();
}
inline
Own
<
ReadableFile
>
ReadableFile
::
clone
()
{
return
cloneFsNode
().
downcast
<
ReadableFile
>
();
}
inline
Own
<
AppendableFile
>
AppendableFile
::
clone
()
{
return
clone
OsHandl
e
().
downcast
<
AppendableFile
>
();
return
clone
FsNod
e
().
downcast
<
AppendableFile
>
();
}
inline
Own
<
File
>
File
::
clone
()
{
return
clone
OsHandl
e
().
downcast
<
File
>
();
}
inline
Own
<
File
>
File
::
clone
()
{
return
clone
FsNod
e
().
downcast
<
File
>
();
}
inline
Own
<
ReadableDirectory
>
ReadableDirectory
::
clone
()
{
return
clone
OsHandl
e
().
downcast
<
ReadableDirectory
>
();
return
clone
FsNod
e
().
downcast
<
ReadableDirectory
>
();
}
inline
Own
<
Directory
>
Directory
::
clone
()
{
return
clone
OsHandl
e
().
downcast
<
Directory
>
();
}
inline
Own
<
Directory
>
Directory
::
clone
()
{
return
clone
FsNod
e
().
downcast
<
Directory
>
();
}
inline
void
Directory
::
transfer
(
PathPtr
toPath
,
WriteMode
toMode
,
PathPtr
fromPath
,
TransferMode
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