Browse Source

put and get can now handle file paths - now compiling (oops)

Denys 5 years ago
parent
commit
b89cea95ff
1 changed files with 8 additions and 6 deletions
  1. 8 6
      cli/src/fileman.cpp

+ 8 - 6
cli/src/fileman.cpp

@@ -136,21 +136,23 @@ std::string FileMan::pathToFilename(std::string path) {
 
   int lastFoundIndex = -1;
 
-  for (int currentIndex = name.find("/"); currentIndex != string::npos;
-       currentIndex = name.find("/", currentIndex + 1)) {
+  for (int currentIndex = path.find("/"); currentIndex != std::string::npos;
+       currentIndex = path.find("/", currentIndex + 1)) {
 
     // check if the "/" was escaped
-    if (currentIndex > 0 && cmd[currentIndex - 1] = '\\')
+    if (currentIndex > 0 && path[currentIndex - 1] == '\\')
       continue;
 
+/*  // check unnecessary, because error occurs when trying to open file anyways
+
     // check if the "/" is at the end of path name
-    if (currentIndex + 1 == name.length) {
+    if (currentIndex + 1 == path.length()) {
       // ERROR: INVALID FILENAME, BECAUSE ENDS WITH "/"
     }
-
+*/
     // otherwise we found a valid "/"
     lastFoundIndex = currentIndex;
   }
 
-  return name.substr(lastFoundIndex + 1);
+  return path.substr(lastFoundIndex + 1);
 }