MCPcopy Create free account
hub / github.com/Haivision/srt / ExtractPath

Function ExtractPath

testing/srt-test-file.cpp:174–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174tuple<string, string> ExtractPath(string path)
175{
176 //string& dir = r_dir;
177 //string& fname = r_fname;
178
179 string directory = path;
180 string filename = "";
181
182 struct stat state;
183 stat(path.c_str(), &state);
184 if (!S_ISDIR(state.st_mode))
185 {
186 // Extract directory as a butlast part of path
187 size_t pos = path.find_last_of("/");
188 if ( pos == string::npos )
189 {
190 filename = path;
191 directory = ".";
192 }
193 else
194 {
195 directory = path.substr(0, pos);
196 filename = path.substr(pos+1);
197 }
198 }
199
200 if (directory[0] != '/')
201 {
202 // Glue in the absolute prefix of the current directory
203 // to make it absolute. This is needed to properly interpret
204 // the fixed uri.
205 static const size_t s_max_path = 4096; // don't care how proper this is
206 char tmppath[s_max_path];
207 char* gwd = getcwd(tmppath, s_max_path);
208 if ( !gwd )
209 {
210 // Don't bother with that now. We need something better for that anyway.
211 throw std::invalid_argument("Path too long");
212 }
213 string wd = gwd;
214
215 directory = wd + "/" + directory;
216 }
217
218 return make_tuple(directory, filename);
219}
220
221bool DoUpload(UriParser& ut, string path, string filename)
222{

Callers 2

UploadFunction · 0.70
DownloadFunction · 0.70

Calls 2

c_strMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected