char const *file = scm_i_string_chars (name);
char const *extensions[] = {"ly", "", 0};
- std::string file_name = global_path.find (file, extensions);
+ string file_name = global_path.find (file, extensions);
/* By default, use base name of input file for output file name,
write output to cwd; do not use root and directory parts of input
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);
}
- std::string init;
+ string init;
if (!init_name_global.empty ())
init = init_name_global;
else
init = "init.ly";
- std::string out_file = out_file_name.to_string ();
+ string out_file = out_file_name.to_string ();
if (init.length () && global_path.find (init).empty ())
{
Sources sources;
sources.set_path (&global_path);
- std::string mapped_fn = map_file_name (file_name);
+ string mapped_fn = map_file_name (file_name);
message (_f ("Processing `%s'", mapped_fn.c_str ()));
progress_indication ("\n");