[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] [PATCH] Implementation of pdf_fsys_disk_item_p
From: |
Zac Brown |
Subject: |
[pdf-devel] [PATCH] Implementation of pdf_fsys_disk_item_p |
Date: |
Sat, 26 Jul 2008 08:27:20 -0700 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080724) |
Hi,
Attached is the merge directive for pdf_fsys_disk_item_p.
Interesting changes from the last revision include, adding proper braces (I'm
still learning this GNU style ;)), using POSIX only commands to create the
function and thus avoiding having #ifdefs to do the same thing (Thank Microsoft
for adding POSXI) and overall simplification of the code.
Note because I used the POSIX fopen, Windows should handle relative paths just
fine and I verified this with my own little simple program.
-Zac
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: http://bzr.savannah.gnu.org/r/pdf/libgnupdf/branches\
# /trunk/
# testament_sha1: a57dacbb4318cc699133735411c15018404a13d5
# timestamp: 2008-07-26 08:20:38 -0700
# base_revision_id: address@hidden
#
# Begin patch
=== modified file 'ChangeLog'
--- ChangeLog 2008-07-25 23:13:29 +0000
+++ ChangeLog 2008-07-26 15:20:13 +0000
@@ -1,3 +1,8 @@
+2008-07-26 Zac Brown <address@hidden>
+ * src/base/pdf-fsys-disk.c (pdf_fsys_disk_item_p): Add implementation
+ for this function. Uses POSIX compliant command for Windows instead of
+ FindFirstFile to minimize crossing of API's.
+
2008-07-26 Jose E. Marchesi <address@hidden>
* doc/gnupdf-hg.texi (Naming Functions): New section.
=== modified file 'src/base/pdf-fsys-disk.c'
--- src/base/pdf-fsys-disk.c 2008-06-13 11:55:20 +0000
+++ src/base/pdf-fsys-disk.c 2008-07-26 15:20:13 +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,22 +473,124 @@
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;
+ FILE *file = NULL;
+
+ 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;
+ }
+
+ file = fopen ((char*)ascii_path, "r");
+ if (file == NULL)
+ {
+ goto error_cleanup;
+ }
+ else
+ {
+ fclose (file);
+ }
+
+ pdf_dealloc (ascii_path);
return PDF_TRUE;
+
+ error_cleanup:
+ if (ascii_path)
+ {
+ pdf_dealloc (ascii_path);
+ }
+ return PDF_FALSE;
}
pdf_bool_t
pdf_fsys_disk_item_readable_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;
+ FILE *file = NULL;
+
+ 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;
+ }
+
+ file = fopen ((char*)ascii_path, "r");
+ if (file == NULL)
+ {
+ goto error_cleanup;
+ }
+ else
+ {
+ fclose (file);
+ }
+
+ pdf_dealloc (ascii_path);
return PDF_TRUE;
+
+ error_cleanup:
+ if (ascii_path)
+ {
+ pdf_dealloc (ascii_path);
+ }
+ return PDF_FALSE;
}
pdf_bool_t
pdf_fsys_disk_item_writable_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;
+ FILE *file = NULL;
+
+ 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;
+ }
+
+ file = fopen ((char*)ascii_path, "r");
+ if (file == NULL)
+ {
+ goto error_cleanup;
+ }
+ else
+ {
+ fclose (file);
+ }
+
+ pdf_dealloc (ascii_path);
return PDF_TRUE;
+
+ error_cleanup:
+ if (ascii_path)
+ {
+ pdf_dealloc (ascii_path);
+ }
+ return PDF_FALSE;
}
pdf_text_t
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWQvmCuEAA4xfgFgweff//38t
ytC////6YAaeffWtNAGWUlRKRKijjJk0YhiaYCBgTTBGCYmmmgAwhxkyaMQxNMBAwJpgjBMTTTQA
YQ4yZNGIYmmAgYE0wRgmJppoAMINpKFPU9T9UeRNADQAaBoAAAAABFIQmEGo0GTQGiGoeUGNINpH
qeiY1B6gkkEaBMCZBMImjCNT1NAZNAAPUwSpFNJWGPN+nh5vOMDyOwzWNQx432mzYe91A5FfNWHK
6HpZsh2sMhhow29G7nZsNIw24dNKkCXXW0oSiOoTibRJAEABRYEFy6hbPJMsl2IZQSgmZfNEmrY2
DdPglazreHTKaLFFJPTQrdxwox3TwGk+U8Z1dWySu22mS70EwmXlt8o9yyCf8a6nW8wyZl74WfLi
/7PkBrZUtiqKfHPPlcgzgb2bJtTKJkxewTsWxW/Zw8z+PDbdy4TWnF7nWrEB8Nj0Fg0sy+TEnztE
DEphoOg6T0GY1B8XigyhmWblvXpyVimF1KSrtOrQcQ3E7wVnq5HCQFBvMeJMFM0eiee18egMoe8G
QYq+n7zFzlHrgXc686UlhlXdlGLYUKVSAsgtj7KGSo/oj3UKEwYQJYnkHU4QO0uHnh8qrxEHfaWv
lSX31cXuuNbAUDw/JRyUAKqHjeNodUmumWwzJEKtHa3jjvYAckXYWyCBTe4JjVLQMhzgL3DKiQUo
8j3j4013QleUATNCsc6IZPRvpa/6pjQqJymSgbSo2mO8zCh9Gt6gYGJW/LWPHJlWMxWmNRa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