mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-29 03:34:56 +01:00
Filepath
Using realpath() to get and use the actual absolute path of the given file
This commit is contained in:
parent
54149584f1
commit
e77e8764cb
1 changed files with 4 additions and 7 deletions
11
zathura.c
11
zathura.c
|
@ -767,20 +767,17 @@ cmd_open(int argc, char** argv)
|
||||||
if(argc == 0 || (int) strlen(argv[0]) == 0)
|
if(argc == 0 || (int) strlen(argv[0]) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gchar* file;
|
char* file = realpath(argv[0], NULL);
|
||||||
|
|
||||||
if(!g_file_test(argv[0], G_FILE_TEST_EXISTS))
|
if(!g_file_test(file, G_FILE_TEST_IS_REGULAR))
|
||||||
{
|
{
|
||||||
notify(ERROR, "File does not exist");
|
notify(ERROR, "File does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_ascii_strncasecmp(argv[0], "file://", strlen("file://")) == 0)
|
Zathura.PDF.document = poppler_document_new_from_file(g_strdup_printf("file://%s", file),
|
||||||
file = g_strdup(argv[0]);
|
(argc == 2) ? argv[1] : NULL, NULL);
|
||||||
else
|
|
||||||
file = g_filename_to_uri(argv[0], NULL, NULL);
|
|
||||||
|
|
||||||
Zathura.PDF.document = poppler_document_new_from_file(file, (argc == 2) ? argv[1] : NULL, NULL);
|
|
||||||
if(!Zathura.PDF.document)
|
if(!Zathura.PDF.document)
|
||||||
{
|
{
|
||||||
notify(WARNING, "Can not open file");
|
notify(WARNING, "Can not open file");
|
||||||
|
|
Loading…
Reference in a new issue