]> git.donarmstrong.com Git - lilypond.git/blobdiff - flower/file-path.cc
Imported sources
[lilypond.git] / flower / file-path.cc
index dd2a5d74d2abe0a7ccdeb0c92e7161fb26f709a4..c59d218cd1f2dce2f4f071cb647005bea0527d7d 100644 (file)
@@ -45,7 +45,7 @@ static String
 dos_to_posix (String path)
 {
   char buf[PATH_MAX];
-  char *filename = path.copy_ch_p ();
+  char *filename = path.get_copy_str0 ();
   /* urg, wtf? char const* argument gets modified! */
   cygwin_conv_to_posix_path (filename, buf);
   delete filename;
@@ -55,7 +55,7 @@ dos_to_posix (String path)
 static String
 dos_to_posix_list (String path)
 {
-  char *filename = path.copy_ch_p ();
+  char *filename = path.get_copy_str0 ();
   int len = cygwin_win32_to_posix_path_list_buf_size (filename);
   if (len < PATH_MAX)
     len = PATH_MAX;
@@ -72,16 +72,16 @@ dos_to_posix_list (String path)
 
 /* Join components to full path. */
 String
-Path::str () const
+Path::to_string () const
 {
   String s;
-  if (!root.empty_b ())
-    s = root + to_str (ROOTSEP);
-  if (!dir.empty_b ())
-    s += dir + to_str (DIRSEP);
+  if (!root.is_empty ())
+    s = root + ::to_string (ROOTSEP);
+  if (!dir.is_empty ())
+    s += dir + ::to_string (DIRSEP);
   s += base;
-  if (!ext.empty_b ())
-    s += to_str (EXTSEP) + ext;
+  if (!ext.is_empty ())
+    s += ::to_string (EXTSEP) + ext;
   return s;
 }
 
@@ -94,31 +94,32 @@ split_path (String path)
 {
 #ifdef __CYGWIN__
   /* All system functions would work, even if we don't convert to
-     posix path, but we'd think that \foe\bar\baz.ly is in the cwd.  */
-  if (testing_level_global & 1)
+     posix path, but we'd think that \foe\bar\baz.ly is in the cwd.
+     On by default.  */
+  if (!(testing_level_global & 1))
     path = dos_to_posix (path);
 #endif
 
   Path p;
-  int i = path.index_i (ROOTSEP);
+  int i = path.index (ROOTSEP);
   if (i >= 0)
     {
-      p.root = path.left_str (i);
-      path = path.right_str (path.length_i () - i - 1);
+      p.root = path.left_string (i);
+      path = path.right_string (path.length () - i - 1);
     }
 
-  i = path.index_last_i (DIRSEP);
+  i = path.index_last (DIRSEP);
   if (i >= 0)
     {
-      p.dir = path.left_str (i);
-      path = path.right_str (path.length_i () - i - 1);
+      p.dir = path.left_string (i);
+      path = path.right_string (path.length () - i - 1);
     }
 
-  i = path.index_last_i ('.');
+  i = path.index_last ('.');
   if (i >= 0)
     {
-      p.base = path.left_str (i);
-      p.ext = path.right_str (path.length_i () - i - 1);
+      p.base = path.left_string (i);
+      p.ext = path.right_string (path.length () - i - 1);
     }
   else
     p.base = path;
@@ -135,13 +136,13 @@ File_path::parse_path (String p)
 
   int l;
   
-  while ((l = p.length_i ()) )
+  while ((l = p.length ()) )
     {
-      int i = p.index_i (PATHSEP);
+      int i = p.index (PATHSEP);
       if (i <0) 
        i = l;
-      add (p.left_str (i));
-      p = p.right_str (l- i - 1);
+      add (p.left_string (i));
+      p = p.right_string (l- i - 1);
     }
 }
 
@@ -158,15 +159,15 @@ File_path::parse_path (String p)
 String
 File_path::find (String nm) const
 {
-  if (!nm.length_i () || (nm == "-") )
+  if (!nm.length () || (nm == "-") )
     return nm;
   for (int i=0; i < size (); i++)
     {
       String path  = elem (i);
-      String sep = to_str (DIRSEP);
-      String right (path.right_str (1));
-      if (path.length_i () && right != sep)
-       path += to_str (DIRSEP);
+      String sep = ::to_string (DIRSEP);
+      String right (path.right_string (1));
+      if (path.length () && right != sep)
+       path += ::to_string (DIRSEP);
 
       path += nm;
 
@@ -176,22 +177,23 @@ File_path::find (String nm) const
        Check if directory. TODO: encapsulate for autoconf
        */
       struct stat sbuf;
-      if (stat (path.ch_C (), &sbuf) == ENOENT)
+      if (stat (path.to_str0 (), &sbuf) != 0)
        continue;
       
       if (! (sbuf.st_mode & __S_IFREG))
        continue;
 #endif
 #if !STAT_MACROS_BROKEN
+      
       struct stat sbuf;
-      if (stat (path.ch_C (), &sbuf) == ENOENT)
+      if (stat (path.to_str0 (), &sbuf) != 0)
        continue;
-      
+
       if (S_ISDIR (sbuf.st_mode))
        continue;
 #endif
 
-      FILE *f = fopen (path.ch_C (), "r"); // ugh!
+      FILE *f = fopen (path.to_str0 (), "r"); // ugh!
       if (f)
        {
          fclose (f);
@@ -209,7 +211,7 @@ File_path::try_add (String s)
 {
   if (s == "")
     s =  ".";
-  FILE  * f = fopen (s.ch_C (), "r");
+  FILE  * f = fopen (s.to_str0 (), "r");
   if (!f)
     return false;
   fclose (f);
@@ -230,7 +232,7 @@ File_path::add (String s)
 }
 
 String
-File_path::str () const
+File_path::to_string () const
 {
   String s;
   for (int i=0; i< size (); i++)