]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/path.cc
release: 0.1.13
[lilypond.git] / flower / path.cc
index 5674ca90a35dc9c728166b52a0d8cdb30394d12f..6625864f6e0fa971da65e2061c32273d38e7dc34 100644 (file)
    @return 4 components of the path. They can be empty
 */
 void
-split_path(String path, 
+split_path (String path, 
           String &drive, String &dirs, String &filebase, String &extension)
 {
-    // peel off components, one by one.
-    int di = path.index_i(':');
-    if (di >= 0) 
+  // peel off components, one by one.
+  int di = path.index_i (':');
+  if (di >= 0) 
        {
-       drive = path.left_str(di + 1);
-       path = path.right_str(path.len() - di -1);
-       } 
-    else
+       drive = path.left_str (di + 1);
+       path = path.right_str (path.len() - di -1);
+         }
+  else
        drive = "";
-    
-    di = path.index_last_i(PATHSEP);
-    if (di >=0) 
+  
+  di = path.index_last_i (PATHSEP);
+  if (di >=0) 
        {
-       dirs = path.left_str(di + 1);
-       path = path.right_str(path.len()-di -1);
-       }
-    else
+       dirs = path.left_str (di + 1);
+       path = path.right_str (path.len()-di -1);
+         }
+  else
        dirs = "";
-    
-    di = path.index_last_i('.');
-    if (di >= 0) 
+  
+  di = path.index_last_i ('.');
+  if (di >= 0) 
        {
-       filebase = path.left_str(di);
-       extension =path.right_str(path.len()-di);       
-       } 
-    else 
+       filebase = path.left_str (di);
+       extension =path.right_str (path.len()-di);      
+         }
+  else 
        {
        extension = "";   
        filebase = path;
-       }
+         }
 }
 
 /** find a file. 
@@ -54,25 +54,30 @@ split_path(String path,
   in any other added path, in this order.
   */
 String
-File_path::find(String nm)const
+File_path::find (String nm) const
 
 {
-    fdebug << "looking for " << nm << ": ";
-    if ( !nm.length_i() || ( nm == "-" ) )
+  fdebug << "looking for " << nm << ": ";
+  if (!nm.length_i() || (nm == "-") )
        return nm;
-    for (int i=0; i < size(); i++) {
+  for (int i=0; i < size(); i++) 
+    {
 
-        String path  = (*this)[i];
-        path+= String(path.length_i()? "/":"")+nm;
+        String path  = elem(i);
+        if (path.length_i() )
+            path += "/";
+        
+        path += nm;
 
         fdebug << path << "? ";
-        FILE *f = fopen(path.ch_C(), "r"); // ugh!
-        if (f) {
+        FILE *f = fopen (path.ch_C(), "r"); // ugh!
+        if (f) 
+          {
             fdebug << "found\n";
-            fclose(f);
+            fclose (f);
             return path;
-        }
+          }
      }
-    fdebug << "\n";
-    return "";
+  fdebug << "\n";
+  return "";
 }