Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yuhao Liu
ogs
Commits
f1523c11
Commit
f1523c11
authored
12 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
Improve docs.
parent
f7c8284a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/FileTools.cpp
+6
-0
6 additions, 0 deletions
BaseLib/FileTools.cpp
BaseLib/FileTools.h
+10
-1
10 additions, 1 deletion
BaseLib/FileTools.h
with
16 additions
and
1 deletion
BaseLib/FileTools.cpp
+
6
−
0
View file @
f1523c11
...
@@ -71,11 +71,17 @@ size_t findLastPathSeparator(std::string const& path)
...
@@ -71,11 +71,17 @@ size_t findLastPathSeparator(std::string const& path)
return
path
.
find_last_of
(
"/
\\
"
);
return
path
.
find_last_of
(
"/
\\
"
);
}
}
/** Finds the position of last dot.
* This could be used to extract file extension.
*/
size_t
findLastDot
(
std
::
string
const
&
path
)
size_t
findLastDot
(
std
::
string
const
&
path
)
{
{
return
path
.
find_last_of
(
"."
);
return
path
.
find_last_of
(
"."
);
}
}
/** Returns a string with file extension as found by getFileExtension()
* dropped.
*/
std
::
string
dropFileExtension
(
std
::
string
const
&
filename
)
std
::
string
dropFileExtension
(
std
::
string
const
&
filename
)
{
{
const
size_t
p
=
findLastDot
(
filename
);
const
size_t
p
=
findLastDot
(
filename
);
...
...
This diff is collapsed.
Click to expand it.
BaseLib/FileTools.h
+
10
−
1
View file @
f1523c11
...
@@ -49,11 +49,17 @@ void truncateFile( std::string const& file_path);
...
@@ -49,11 +49,17 @@ void truncateFile( std::string const& file_path);
/**
/**
* Extracts basename from given pathname with extension.
* Extracts basename from given pathname with extension.
*
* Returns a string containing everything after the last path separator.
* If the the pathname does not contain a path separator original pathname is
* returned.
*/
*/
std
::
string
extractBaseName
(
std
::
string
const
&
pathname
);
std
::
string
extractBaseName
(
std
::
string
const
&
pathname
);
/**
/**
* Extracts basename from given pathname without its extension.
* Extracts basename from given pathname without its extension.
*
* Same as extractBaseName(), but drops the file extension too.
*/
*/
std
::
string
extractBaseNameWithoutExtension
(
std
::
string
const
&
pathname
);
std
::
string
extractBaseNameWithoutExtension
(
std
::
string
const
&
pathname
);
...
@@ -70,12 +76,15 @@ std::string getFileExtension(std::string const& filename);
...
@@ -70,12 +76,15 @@ std::string getFileExtension(std::string const& filename);
bool
hasFileExtension
(
std
::
string
const
&
extension
,
std
::
string
const
&
filename
);
bool
hasFileExtension
(
std
::
string
const
&
extension
,
std
::
string
const
&
filename
);
/**
/**
* Checks if file_name already contains a qualified path and if not copies the path from source.
* Checks if file_name already contains a qualified path and if not copies the
* path from source.
*/
*/
std
::
string
copyPathToFileName
(
const
std
::
string
&
file_name
,
const
std
::
string
&
source
);
std
::
string
copyPathToFileName
(
const
std
::
string
&
file_name
,
const
std
::
string
&
source
);
/**
/**
* Extracts the path of a pathname.
* Extracts the path of a pathname.
*
* Returns a string up to the last path separator not including it.
*/
*/
std
::
string
extractPath
(
std
::
string
const
&
pathname
);
std
::
string
extractPath
(
std
::
string
const
&
pathname
);
}
// end namespace BaseLib
}
// end namespace BaseLib
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment