Skip to content

Commit a1785a9

Browse files
author
Andreas Bilke
committed
Merge pull request #96 from rschroll/cwd
Set the CWD to be the directory of the .pdfpc file
2 parents eaf67b1 + 25461d1 commit a1785a9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/classes/metadata/pdf.vala

+5-2
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,13 @@ namespace pdfpc.Metadata {
177177
void fill_path_info(string fname) {
178178
int l = fname.length;
179179

180-
if (l > 6 && fname[l-6:l] != ".pdfpc") {
180+
if (l < 6 || fname[l-6:l] != ".pdfpc") {
181181
this.pdf_fname = fname;
182182
int extension_index = fname.last_index_of(".");
183-
this.pdfpc_fname = fname[0:extension_index] + ".pdfpc";
183+
if (extension_index > -1)
184+
this.pdfpc_fname = fname[0:extension_index] + ".pdfpc";
185+
else
186+
this.pdfpc_fname = fname + ".pdfpc";
184187
} else {
185188
this.pdfpc_fname = fname;
186189
}

src/pdfpc.vala

+3-1
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ namespace pdfpc {
236236
Options.windowed = true;
237237
}
238238

239+
GLib.Environment.set_current_dir(GLib.Path.get_dirname(pdfFilename));
240+
239241
pdfpc.Metadata.NotesPosition notes_position = pdfpc.Metadata.NotesPosition.from_string(Options.notes_position);
240-
var metadata = new Metadata.Pdf( pdfFilename, notes_position );
242+
var metadata = new Metadata.Pdf(GLib.Path.get_basename(pdfFilename), notes_position);
241243
if ( Options.duration != 987654321u )
242244
metadata.set_duration(Options.duration);
243245

0 commit comments

Comments
 (0)