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
a714936e
Commit
a714936e
authored
Dec 21, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add evalNative() / toNativeString() helpers to Path.
These use Win32 variants if and only if compiling for Windows.
parent
47e755eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
filesystem.h
c++/src/kj/filesystem.h
+47
-0
No files found.
c++/src/kj/filesystem.h
View file @
a714936e
...
...
@@ -171,6 +171,12 @@ public:
// the colon, will become the first component of the path, e.g. "c:\foo" becomes {"c:", "foo"}.
// - A network path like "\\host\share\path" is parsed as {"host", "share", "path"}.
Path
evalNative
(
StringPtr
pathText
)
const
&
;
Path
evalNative
(
StringPtr
pathText
)
&&
;
// Alias for either eval() or evalWin32() depending on the target platform. Use this when you are
// parsing a path provided by a user and you want the user to be able to use the "natural" format
// for their platform.
String
toWin32String
(
bool
absolute
=
false
)
const
;
// Converts the path to a Win32 path string, as you might display to a user.
//
...
...
@@ -184,6 +190,11 @@ public:
// Windows, such as if it contains backslashes (within a path component), colons, or special
// names like "con".
String
toNativeString
(
bool
absolute
=
false
)
const
;
// Alias for either toString() or toWin32String() depending on the target platform. Use this when
// you are formatting a path to display to a user and you want to present it in the "natural"
// format for the user's platform.
Array
<
wchar_t
>
forWin32Api
(
bool
absolute
)
const
;
// Like toWin32String, but additionally:
// - Converts the path to UTF-16, with a NUL terminator included.
...
...
@@ -257,7 +268,9 @@ public:
bool
startsWith
(
PathPtr
prefix
)
const
;
bool
endsWith
(
PathPtr
suffix
)
const
;
Path
evalWin32
(
StringPtr
pathText
)
const
;
Path
evalNative
(
StringPtr
pathText
)
const
;
String
toWin32String
(
bool
absolute
=
false
)
const
;
String
toNativeString
(
bool
absolute
=
false
)
const
;
Array
<
wchar_t
>
forWin32Api
(
bool
absolute
)
const
;
// Equivalent to the corresponding methods of `Path`.
...
...
@@ -986,6 +999,40 @@ inline String PathPtr::toWin32String(bool absolute) const {
return
toWin32StringImpl
(
absolute
,
false
);
}
#if _WIN32
inline
Path
Path
::
evalNative
(
StringPtr
pathText
)
const
&
{
return
evalWin32
(
pathText
);
}
inline
Path
Path
::
evalNative
(
StringPtr
pathText
)
&&
{
return
kj
::
mv
(
*
this
).
evalWin32
(
pathText
);
}
inline
String
Path
::
toNativeString
(
bool
absolute
)
const
{
return
toWin32String
(
absolute
);
}
inline
Path
PathPtr
::
evalNative
(
StringPtr
pathText
)
const
{
return
evalWin32
(
pathText
);
}
inline
String
PathPtr
::
toNativeString
(
bool
absolute
)
const
{
return
toWin32String
(
absolute
);
}
#else
inline
Path
Path
::
evalNative
(
StringPtr
pathText
)
const
&
{
return
eval
(
pathText
);
}
inline
Path
Path
::
evalNative
(
StringPtr
pathText
)
&&
{
return
kj
::
mv
(
*
this
).
eval
(
pathText
);
}
inline
String
Path
::
toNativeString
(
bool
absolute
)
const
{
return
toString
(
absolute
);
}
inline
Path
PathPtr
::
evalNative
(
StringPtr
pathText
)
const
{
return
eval
(
pathText
);
}
inline
String
PathPtr
::
toNativeString
(
bool
absolute
)
const
{
return
toString
(
absolute
);
}
#endif // _WIN32, else
inline
Own
<
FsNode
>
FsNode
::
clone
()
{
return
cloneFsNode
().
downcast
<
FsNode
>
();
}
inline
Own
<
ReadableFile
>
ReadableFile
::
clone
()
{
return
cloneFsNode
().
downcast
<
ReadableFile
>
();
}
inline
Own
<
AppendableFile
>
AppendableFile
::
clone
()
{
...
...
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