MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / CurrentDirs

Method CurrentDirs

MonaBase/sources/FileSystem.cpp:94–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94FileSystem::CurrentDirs::CurrentDirs() : _isNull(false) {
95 string current;
96 int n(0);
97 current.resize(PATH_MAX);
98#if defined(_WIN32)
99 char* test(&current[0]);
100 n = GetCurrentDirectoryA(PATH_MAX, test);
101 if (n < 0 || n > PATH_MAX)
102 n = 0;
103#else
104 if (getcwd(&current[0], PATH_MAX)) {
105 n = strlen(current.c_str());
106 emplace_back("/");
107 }
108#endif
109 current.resize(n);
110 _isNull = n == 0;
111 if (_isNull) {
112 // try with parrent of CurrentApp
113 if (_CurrentApp)
114 GetParent(_CurrentApp, current);
115 else // else with Home
116 current = _Home;
117 }
118
119 String::ForEach forEach([this](UInt32 index,const char* value){
120 Directory dir(empty() ? String::Empty : back());
121 dir.append(value).append("/");
122 dir.name.assign(value);
123 dir.extPos = dir.name.find_last_of('.');
124 emplace_back(move(dir));
125 return true;
126 });
127 String::Split(current, "/\\", forEach, String::SPLIT_IGNORE_EMPTY);
128 if (empty())
129 emplace_back("/"); // if nothing other possible, root!
130}
131
132
133#if defined(_WIN32)

Callers

nothing calls this directly

Calls 2

resizeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected