source file of the Flower Library
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include <cstdio>
#include <cerrno>
+using namespace std;
#include "config.hh"
#include <sys/cygwin.h>
#endif
-/* We don't have multiple roots, set this to '\0'? */
#ifndef ROOTSEP
#define ROOTSEP ':'
#endif
static String
dos_to_posix (String file_name)
{
- char buf[PATH_MAX];
+ char buf[PATH_MAX] = "";
char *s = file_name.get_copy_str0 ();
- /* urg, wtf? char const* argument gets modified! */
- cygwin_conv_to_posix_path (s, buf);
+ /* ugh: char const* argument gets modified. */
+ int fail = cygwin_conv_to_posix_path (s, buf);
delete s;
- return buf;
+ if (!fail)
+ return buf;
+ return file_name;
}
#endif /* __CYGWIN__ */
static String
slashify (String file_name)
{
- if (file_name.index ('/') >= 0)
- return file_name;
file_name.substitute ('\\', '/');
- file_name.substitute ("\"", "\\\"");
- file_name.substitute ("\'", "\\\'");
+ file_name.substitute ("//", "/");
return file_name;
}
#endif /* __MINGW32__ */
if (!root_.is_empty ())
s = root_ + ::to_string (ROOTSEP);
if (!dir_.is_empty ())
- s += dir_ + ::to_string (DIRSEP);
+ {
+ s += dir_;
+ if (!base_.is_empty () || !ext_.is_empty ())
+ s += ::to_string (DIRSEP);
+ }
s += base_;
if (!ext_.is_empty ())
s += ::to_string (EXTSEP) + ext_;
return s;
}
-char const *
-File_name::to_str0 () const
-{
- return to_string ().to_str0 ();
-}
-
File_name::File_name (String file_name)
{
#ifdef __CYGWIN__
else
base_ = file_name;
}
+
+bool
+File_name::is_absolute () const
+{
+ /*
+ Hmm. Is c:foo absolute?
+ */
+ return (dir_.length () && dir_[0] == DIRSEP) || root_.length ();
+}