-/* We don't have multiple roots, set this to '\0'? */
-#ifndef ROOTSEP
-#define ROOTSEP ':'
-#endif
-
-#ifndef DIRSEP
-#define DIRSEP '/'
-#endif
-
-#ifndef EXTSEP
-#define EXTSEP '.'
-#endif
-
-
-
-#ifdef __CYGWIN__
-static String
-dos_to_posix (String path)
-{
- char buf[PATH_MAX];
- char *filename = path.copy_ch_p ();
- /* urg, wtf? char const* argument gets modified! */
- cygwin_conv_to_posix_path (filename, buf);
- delete filename;
- return buf;
-}
-
-static String
-dos_to_posix_list (String path)
-{
- char *filename = path.copy_ch_p ();
- int len = cygwin_win32_to_posix_path_list_buf_size (filename);
- if (len < PATH_MAX)
- len = PATH_MAX;
- char *buf = new char[len];
- /* urg, wtf? char const* argument gets modified! */
- cygwin_win32_to_posix_path_list (filename, buf);
- delete filename;
-
- String ret = buf;
- delete buf;
- return ret;
-}
-#endif /* __CYGWIN__ */
-
-/* Join components to full path. */
-String
-Path::str () const
-{
- String s;
- if (!root.empty_b ())
- s = root + to_str (ROOTSEP);
- if (!dir.empty_b ())
- s += dir + to_str (DIRSEP);
- s += base;
- if (!ext.empty_b ())
- s += to_str (EXTSEP) + ext;
- return s;
-}
-
-/**
- @param path the original full filename
- @return 4 components of the path. They can be empty
-*/
-Path
-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.
- On by default. */
- if (!(testing_level_global & 1))
- path = dos_to_posix (path);
-#endif
-
- Path p;
- int i = path.index_i (ROOTSEP);
- if (i >= 0)
- {
- p.root = path.left_str (i);
- path = path.right_str (path.length_i () - i - 1);
- }
-
- i = path.index_last_i (DIRSEP);
- if (i >= 0)
- {
- p.dir = path.left_str (i);
- path = path.right_str (path.length_i () - i - 1);
- }
-
- i = path.index_last_i ('.');
- if (i >= 0)
- {
- p.base = path.left_str (i);
- p.ext = path.right_str (path.length_i () - i - 1);
- }
- else
- p.base = path;
- return p;
-}
-