pdf-devel
[Top][All Lists]
Advanced

[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 [try 2]
Date: Sun, 06 Jul 2008 13:49:16 -0700
User-agent: Thunderbird 2.0.0.14 (X11/20080505)

Implement pdf_fsys_disk_item_p in base/pdf-fsys-disk.c
? config.guess
? config.sub
? configure
? libtool
? ltmain.sh
? doc/Makefile
? doc/Makefile.in
? lib/.deps
? lib/.libs
? lib/Makefile
? lib/Makefile.in
? lib/basename.lo
? lib/charset.alias
? lib/configmake.h
? lib/dirname.lo
? lib/exitfail.lo
? lib/fpurge.lo
? lib/freading.lo
? lib/gl_array_list.lo
? lib/gl_linkedhash_list.lo
? lib/gl_list.lo
? lib/libgnu.la
? lib/localcharset.lo
? lib/localename.lo
? lib/math.h
? lib/ref-add.sed
? lib/ref-del.sed
? lib/stdio.h
? lib/stdlib.h
? lib/string.h
? lib/stripslash.lo
? lib/sys
? lib/unistd.h
? lib/xalloc-die.lo
? lib/xmalloc.lo
? lib/xstrndup.lo
? prmgt/Makefile
? prmgt/Makefile.in
? prmgt/apic2wiki
? prmgt/docfuncs
? prmgt/pmccabe2html
? prmgt/testlog2wiki
? prmgt/tsdfuncs
? src/.deps
? src/.libs
? src/Makefile
? src/Makefile.in
? src/config.h
? src/config.h.in
? src/extract-public-hdr
? src/libgnupdf.la
? src/pdf-alloc.lo
? src/pdf-base.lo
? src/pdf-error.lo
? src/pdf-fsys-disk.lo
? src/pdf-fsys.lo
? src/pdf-global.lo
? src/pdf-hash.lo
? src/pdf-list.lo
? src/pdf-stm-f-a85.lo
? src/pdf-stm-f-ahex.lo
? src/pdf-stm-f-fax.lo
? src/pdf-stm-f-flate.lo
? src/pdf-stm-f-lzw.lo
? src/pdf-stm-f-null.lo
? src/pdf-stm-f-pred.lo
? src/pdf-stm-f-rl.lo
? src/pdf-stm-file.lo
? src/pdf-stm-mem.lo
? src/pdf-stm.lo
? src/pdf-text-context.lo
? src/pdf-text-encoding.lo
? src/pdf-text-filter.lo
? src/pdf-text-host-encoding.lo
? src/pdf-text-ucd-case.lo
? src/pdf-text-ucd-combclass.lo
? src/pdf-text-ucd-gencat.lo
? src/pdf-text-ucd-proplist.lo
? src/pdf-text-ucd-wordbreak.lo
? src/pdf-text.lo
? src/pdf-time-context.lo
? src/pdf-time-string.lo
? src/pdf-time.lo
? src/pdf-types.lo
? src/pdf.h
? src/stamp-h1
? src/base/pdf-fsys-disk.c-backup
? torture/Makefile
? torture/Makefile.in
? torture/unit/.deps
? torture/unit/.libs
? torture/unit/Makefile
? torture/unit/Makefile.in
? torture/unit/runtests
? utils/.deps
? utils/.libs
? utils/Makefile
? utils/Makefile.in
? utils/pdf-filter
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    6 Jul 2008 20:40:08 -0000
@@ -36,6 +36,7 @@
 #include <pdf-types.h>
 #include <pdf-error.h>
 #include <pdf-fsys-disk.h>
+#include <pdf-text.h>
 
 #ifndef PDF_HOST_WIN32
 #include <sys/statvfs.h>
@@ -472,8 +473,47 @@
 pdf_bool_t
 pdf_fsys_disk_item_p (pdf_text_t path_name)
 {
-  /* FIXME: Please implement me :D */
+  pdf_char_t* ascii_path;
+  pdf_size_t ascii_path_len;
+  pdf_status_t ret_code;
+#ifdef PDF_HOST_WIN32
+  HANDLE hFile = NULL;
+  WIN32_FIND_DATA data;
+#else
+  FILE *file = NULL;
+#endif
+
+  if (path_name == NULL)
+    {
+      return PDF_FALSE;
+    }
+
+  ret_code = pdf_text_get_host (&ascii_path, &ascii_path_len, path_name, 
pdf_text_get_host_encoding());
+
+  if (ret_code != PDF_OK)
+    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 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]