Welcome to mirror list, hosted at ThFree Co, Russian Federation.

file_name_utils.hpp « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 83424b14dd140dec3ac2e5bc197b099efab940d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include <initializer_list>
#include <string>
#include <utility>

namespace base
{
/// Remove extension from file name.
void GetNameWithoutExt(std::string & name);
std::string FilenameWithoutExt(std::string name);
/// @return File extension with the dot or empty std::string if no extension found.
std::string GetFileExtension(std::string const & name);

/// Get file name from full path.
void GetNameFromFullPath(std::string & name);

/// Get file name from full path without extension.
std::string GetNameFromFullPathWithoutExt(std::string const & path);

/// Returns all but last components of the path. After dropping the last
/// component, all trailing slashes are removed, unless the result is a
/// root directory. If the argument is a single component, returns ".".
std::string GetDirectory(std::string const & path);

/// Get folder separator for specific platform
std::string GetNativeSeparator();

/// Add the terminating slash to the folder path std::string if it's not already there.
std::string AddSlashIfNeeded(std::string const & path);

inline std::string JoinPath(std::string const & file) { return file; }

/// Create full path from some folder using native folders separator.
template <typename... Args>
std::string JoinPath(std::string const & folder, Args &&... args)
{
  if (folder.empty())
    return JoinPath(std::forward<Args>(args)...);

  return AddSlashIfNeeded(folder) + JoinPath(std::forward<Args>(args)...);
}
}  // namespace base