[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] [PATCH] Implement pdf_fsys_disk_item_p in base/pdf-fsys-disk
From: |
Zac Brown |
Subject: |
[pdf-devel] [PATCH] Implement pdf_fsys_disk_item_p in base/pdf-fsys-disk.c |
Date: |
Fri, 04 Jul 2008 14:04:36 -0700 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080505) |
Implement pdf_fsys_disk_item_p in base/pdf-fsys-disk.c
Index: src/base/pdf-fsys-disk.c
===================================================================
RCS file: /cvsroot/pdf/libgnupdf/src/base/pdf-fsys-disk.c,v
retrieving revision 1.15
diff -u -r1.15 pdf-fsys-disk.c
--- src/base/pdf-fsys-disk.c 13 Jun 2008 09:55:20 -0000 1.15
+++ src/base/pdf-fsys-disk.c 4 Jul 2008 20:53:51 -0000
@@ -36,6 +36,7 @@
#include <pdf-types.h>
#include <pdf-error.h>
#include <pdf-fsys-disk.h>
+#include <pdf-text-host-encoding.h>
#ifndef PDF_HOST_WIN32
#include <sys/statvfs.h>
@@ -56,6 +57,9 @@
static pdf_bool_t
pdf_fsys_disk_win32_device_p (pdf_text_t path);
+static pdf_bool_t
+pdf_fsys_get_ascii_str (pdf_text_t path, pdf_char_t* ascii_path);
+
/*
* Filesystem Interface Implementation
*/
@@ -472,8 +476,47 @@
pdf_bool_t
pdf_fsys_disk_item_p (pdf_text_t path_name)
{
- /* FIXME: Please implement me :D */
+ pdf_char_t* ascii_path;
+#ifdef PDF_HOST_WIN32
+ HANDLE hFile = NULL;
+ WIN32_FIND_DATA data;
+#else
+ FILE *file = NULL;
+#endif
+
+ if (path_name == NULL)
+ {
+ return PDF_FALSE;
+ }
+
+ ascii_path = (pdf_char_t*)pdf_alloc (path_name->size / 4);
+ if (ascii_path == NULL)
+ goto error_cleanup;
+
+ if (!pdf_fsys_get_ascii_str (path_name, ascii_path))
+ goto error_cleanup;
+
+#ifdef PDF_HOST_WIN32
+ hFile = FindFirstFile (ascii_path, &data);
+ if (hFile == NULL)
+ goto error_cleanup;
+ else
+ FindClose (hFile);
+#else
+ file = fopen ((char*)ascii_path, "r");
+ if (file == NULL)
+ goto error_cleanup;
+ else
+ fclose (file);
+#endif
+
+ pdf_dealloc (ascii_path);
return PDF_TRUE;
+
+ error_cleanup:
+ if (ascii_path)
+ pdf_dealloc (ascii_path);
+ return PDF_FALSE;
}
pdf_bool_t
@@ -817,4 +860,28 @@
return device_p;
}
+static pdf_bool_t
+pdf_fsys_get_ascii_str (pdf_text_t path, pdf_char_t* ascii_path)
+{
+ pdf_text_host_encoding_t enc;
+ pdf_size_t ascii_path_len;
+
+ if (path == NULL)
+ return PDF_FALSE;
+
+ if (ascii_path == NULL)
+ return PDF_FALSE;
+
+ strcpy ((char*)enc.name, "ASCII");
+
+ if (pdf_text_utf32he_to_host (path->data,
+ path->size,
+ enc,
+ &ascii_path,
+ &ascii_path_len) != PDF_OK)
+ return PDF_FALSE;
+
+ return PDF_TRUE;
+}
+
/* End of pdf-fsys-disk.c */
- [pdf-devel] [PATCH] Implement pdf_fsys_disk_item_p in base/pdf-fsys-disk.c,
Zac Brown <=