V-ART
file.cpp
Go to the documentation of this file.
1 
5 #include "vart/file.h"
6 
7 using namespace std;
8 
9 std::string VART::File::GetPathFromString(const std::string& fileName)
10 {
11  std::string path("");
12  std::size_t pos;
13 
14 #ifdef __linux__
15  pos = fileName.find_last_of('/');
16  if( pos!=string::npos && pos<fileName.size() )
17  {
18  path = fileName.substr(0, pos+1 );
19  }
20 #endif
21 
22 #ifdef WIN32
23  //Windows systems acept the character '/' as a directory separator.
24  //Replace with the correct directory separator ('\').
25  std::string file( fileName );
26 
27  pos = file.find_last_of('/');
28  while(pos!=string::npos)
29  {
30  if( pos<file.size() )
31  {
32  file.replace( pos, 1, "\\" );
33  }
34  pos = file.find_last_of('/');
35  }
36  pos = file.find_last_of('\\');
37  if( pos!=string::npos && pos<file.size() )
38  {
39  path = file.substr(0, pos+1 );
40  }
41 #endif
42 
43  return path;
44 }
Header file for V-ART class "File".
static std::string GetPathFromString(const std::string &fileName)
Definition: file.cpp:9