]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/path.cc
release: 0.0.44
[lilypond.git] / flower / path.cc
index 2fd7eea3cb5b1321f66e92310d0c32bf11b8342c..a0bbaca44f472dd14736ad7a5853896a40dbd3fa 100644 (file)
@@ -3,41 +3,44 @@
 */
 #include <stdio.h>
 #include "path.hh"
+#include "flower-debug.hh"
 
 #ifndef PATHSEP
 #define PATHSEP '/'
 #endif
 
-
+/**
+   @param path the original full filename
+   @return 4 components of the path. They can be empty
+*/
 void
 split_path(String path, 
           String &drive, String &dirs, String &filebase, String &extension)
 {
     // peel off components, one by one.
-    int di = path.pos(':');
-    if (di) 
+    int di = path.index_i(':');
+    if (di >= 0
        {
-       drive = path.left(di);
-       path = path.right(path.len() - di);
+       drive = path.left_str(di + 1);
+       path = path.right_str(path.len() - di -1);
        } 
     else
        drive = "";
     
-    di = path.lastPos(PATHSEP);
-    if (di) 
+    di = path.index_last_i(PATHSEP);
+    if (di >=0
        {
-       dirs = path.left(di);
-       path = path.right(path.len()-di);
+       dirs = path.left_str(di + 1);
+       path = path.right_str(path.len()-di -1);
        }
     else
        dirs = "";
     
-    di = path.lastPos('.');
-    if (di) 
+    di = path.index_last_i('.');
+    if (di >= 0
        {
-       di --; // don't forget '.'
-       filebase = path.left(di);
-       extension =path.right(path.len()-di);   
+       filebase = path.left_str(di);
+       extension =path.right_str(path.len()-di);       
        } 
     else 
        {
@@ -45,11 +48,6 @@ split_path(String path,
        filebase = path;
        }
 }
-/**
-   INPUT: path the original full filename
-   OUTPUT: 4 components of the path. They can be empty
-*/
-
 
 File_path::File_path(String pref)
 {
@@ -58,24 +56,28 @@ File_path::File_path(String pref)
 }
 
 
-///
+/** find a file. 
+  It will search in the current dir, in the construction-arg, and
+  in any other added path, in this order.
+  */
 String
-File_path::find(String nm)
+File_path::find(String nm)const
+
 {
-     for (int i=0; i < size(); i++) {
+    fdebug << "looking for " << nm ;
+    for (int i=0; i < size(); i++) {
+
         String path  = (*this)[i];
         path+= "/"+nm;
 
-
+        fdebug << path << "? ";
         FILE *f = fopen(path, "r"); // ugh!
         if (f) {
+            fdebug << "found\n";
             fclose(f);
             return path;
         }
      }
-     return "";
+    fdebug << "\n";
+    return "";
 }
-/**
-  It will search in the current dir, in the construction-arg, and
-  in any other added path, in this order.
-  */