Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
dd67b338
Commit
dd67b338
authored
Jul 27, 2018
by
Mark OLESEN
Browse files
ENH: add fileName /= operator (similar to std::filesystem::path)
parent
0b703011
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/OSspecific/POSIX/POSIX.C
View file @
dd67b338
...
...
@@ -824,7 +824,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
// If dest is a directory, create the destination file name.
if
(
destFile
.
type
()
==
fileName
::
DIRECTORY
)
{
destFile
=
destFile
/
src
.
name
();
destFile
/
=
src
.
name
();
}
// Make sure the destination directory exists.
...
...
@@ -864,7 +864,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
// If dest is a directory, create the destination file name.
if
(
destFile
.
type
()
==
fileName
::
DIRECTORY
)
{
destFile
=
destFile
/
src
.
name
();
destFile
/
=
src
.
name
();
}
// Make sure the destination directory exists.
...
...
@@ -880,7 +880,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
// If dest is a directory, create the destination file name.
if
(
destFile
.
type
()
==
fileName
::
DIRECTORY
)
{
destFile
=
destFile
/
src
.
components
().
last
();
destFile
/
=
src
.
components
().
last
();
}
// Make sure the destination directory exists.
...
...
src/OpenFOAM/primitives/strings/fileName/fileName.C
View file @
dd67b338
...
...
@@ -533,6 +533,30 @@ void Foam::fileName::operator=(const char* str)
}
Foam
::
fileName
&
Foam
::
fileName
::
operator
/=
(
const
string
&
other
)
{
fileName
&
s
=
*
this
;
if
(
s
.
size
())
{
if
(
other
.
size
())
{
// Two non-empty strings: can concatenate
s
.
append
(
"/"
);
s
.
append
(
other
);
}
}
else
if
(
other
.
size
())
{
// Or, if the first string is empty
s
=
other
;
}
return
*
this
;
}
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
Foam
::
fileName
Foam
::
operator
/
(
const
string
&
a
,
const
string
&
b
)
...
...
src/OpenFOAM/primitives/strings/fileName/fileName.H
View file @
dd67b338
...
...
@@ -130,7 +130,7 @@ public:
fileName
(
Istream
&
is
);
// Member
f
unctions
// Member
F
unctions
//- Is this character valid for a fileName?
inline
static
bool
valid
(
char
c
);
...
...
@@ -188,7 +188,7 @@ public:
fileName
clean
()
const
;
// Interrogation
// Interrogation
//- Return the file type: FILE, DIRECTORY, LINK or UNDEFINED.
// LINK is only returned if followLink=false
...
...
@@ -210,7 +210,7 @@ public:
inline
bool
isBackup
()
const
;
// Decomposition
// Decomposition
//- Return basename (part beyond last /), including its extension
// The result normally corresponds to a Foam::word
...
...
@@ -316,7 +316,7 @@ public:
// Member operators
// Assignment
// Assignment
//- Copy, no character validation required
void
operator
=
(
const
fileName
&
str
);
...
...
@@ -334,6 +334,13 @@ public:
void
operator
=
(
const
char
*
str
);
// Other operators
//- Append a path element with '/' separator.
// No '/' separator is added if this or the argument are empty.
fileName
&
operator
/=
(
const
string
&
other
);
// IOstream operators
friend
Istream
&
operator
>>
(
Istream
&
is
,
fileName
&
fn
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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