-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPath.h
More file actions
47 lines (35 loc) · 1.67 KB
/
Path.h
File metadata and controls
47 lines (35 loc) · 1.67 KB
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
44
45
46
47
#pragma once
#include <string>
namespace ZipSync {
/**
* File path or http URL in both absolute and relative format.
*/
struct PathAR {
std::string abs;
std::string rel;
static bool IsHttp(const std::string &path);
static bool IsAbsolute(const std::string &path);
bool IsUrl() const { return IsHttp(abs); }
std::string GetRootDir() const;
static PathAR FromAbs(std::string absPath, std::string rootDir);
static PathAR FromRel(std::string relPath, std::string rootDir);
};
//append filename with prefix (e.g. "C:/__download__models.pk4" from "C:/models.pk4").
std::string PrefixFile(std::string absPath, std::string prefix);
//remove prefix from filename (e.g. "C:/models.pk4" from "C:/__download__models.pk4").
std::string UnPrefixFile(std::string absPath, std::string prefix);
//given a path to file, returns path to the directory it belongs to
std::string GetDirPath(std::string somePath);
//given a path to file, returns the filename
std::string GetFilename(std::string somePath);
std::string GetFullPath(const std::string &zipPath, const std::string &filename);
void ParseFullPath(const std::string &fullPath, std::string &zipPath, std::string &filename);
//the functions below actually interact with filesystem!
bool IfFileExists(const std::string &path);
void RemoveFile(const std::string &path);
void RenameFile(const std::string &oldPath, const std::string &newPath);
bool CreateDir(const std::string &dirPath);
bool RemoveDirectoryIfEmpty(const std::string dirPath);
void CreateDirectoriesForFile(const std::string &filePath, const std::string &rootPath);
void PruneDirectoriesAfterFileRemoval(const std::string &filePath, const std::string &rootPath);
}