pdf conversion behaviour.
* flower/file-name.cc (dir_name)
(get_working_directory): Move from relocate.cc.
* lily/relocate.cc (setup_paths): Remove rogue stat calls.
* lily/relocate.cc: Encapsulate sys/stat.h in
HAVE_STAT_H.
+2006-04-15 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/lily-parser-scheme.cc: Use them to fix --output=DIR/BASE
+ pdf conversion behaviour.
+
+ * flower/file-name.cc (dir_name)
+ (get_working_directory): Move from relocate.cc.
+
+ * lily/relocate.cc (setup_paths): Remove rogue stat calls.
+
+ * lily/relocate.cc: Encapsulate sys/stat.h in
+ HAVE_STAT_H.
+
2006-04-14 Graham Percival <gpermus@gmail.com>
* Documentation/user/ various: small updates from Cameron
J. Leung
Harald Wellmann
Orm Finnendahl
+Rick Hansen
Stephen Carter
Werner Lemberg
#include <cstdio>
#include <cerrno>
+#include <unistd.h>
+
using namespace std;
#include "config.hh"
return file_name;
}
+string
+dir_name (string const file_name)
+{
+ string s = file_name;
+ s = slashify (s);
+ ssize n = s.length ();
+ if (n && s[n - 1] == '/')
+ s[n - 1] = 0;
+ s = s.substr (0, s.rfind ('/'));
+ return s;
+}
+
+string
+get_working_directory ()
+{
+ char cwd[PATH_MAX];
+ getcwd (cwd, PATH_MAX);
+
+ return string (cwd);
+}
+
/* Join components to full file_name. */
string
File_name::to_string () const
#include "std-vector.hh"
#include "std-string.hh"
+std::string dir_name (std::string const file_name);
+std::string get_working_directory ();
+
class File_name
{
public:
#ifndef RELOCATE_HH
#define RELOCATE_HH
-
-
#include "std-string.hh"
int sane_putenv (char const *key, string value, bool overwrite);
if (!output_name_global.empty ())
{
/* Interpret --output=DIR to mean --output=DIR/BASE. */
+ string dir;
if (is_dir (output_name_global))
{
- char cwd[PATH_MAX];
- getcwd (cwd, PATH_MAX);
-
- if (output_name_global != cwd)
- {
- global_path.prepend (cwd);
- message (_f ("Changing working directory to `%s'",
- output_name_global.c_str ()));
- chdir (output_name_global.c_str ());
- }
+ dir = output_name_global;
output_name_global = "";
}
+ else
+ dir = dir_name (output_name_global);
+ if (dir != "" && dir != "." && dir != get_working_directory ())
+ {
+ global_path.prepend (get_working_directory ());
+ message (_f ("Changing working directory to `%s'",
+ dir.c_str ()));
+ chdir (dir.c_str ());
+ }
else
out_file_name = File_name (output_name_global);
}
#include "config.hh"
-#include <sys/stat.h>
-#include <unistd.h>
-
#if HAVE_GETTEXT
#include <libintl.h>
#endif
return -1;
}
-string
-dir_name (string const file_name)
-{
- string s = file_name;
- replace_all (s, '\\', '/');
- ssize n = s.length ();
- if (n && s[n - 1] == '/')
- s[n - 1] = 0;
- s = s.substr (0, s.rfind ('/'));
- return s;
-}
-
#ifdef __MINGW32__
#include <winbase.h>
#endif
prepend_env_path ("PATH", bindir);
}
-string
-get_working_directory ()
-{
- char cwd[PATH_MAX];
- getcwd (cwd, PATH_MAX);
-
- return string (cwd);
-}
-
void
setup_paths (char const *argv0_ptr)
{
*/
- struct stat statbuf;
string build_prefix_current = prefix_directory + "/share/lilypond/" "current";
string build_prefix_version = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION;
- if (stat (build_prefix_version.c_str (), &statbuf) == 0)
+ if (is_dir (build_prefix_version.c_str ()))
prefix_directory = build_prefix_version;
- else if (stat (build_prefix_current.c_str (), &statbuf) == 0)
+ else if (is_dir (build_prefix_current.c_str ()))
prefix_directory = build_prefix_current;
-
/* Adding mf/out make lilypond unchanged source directory, when setting
LILYPONDPREFIX to lilypond-x.y.z */