Mercurial > audlegacy
comparison libaudacious/vfs_stdio.c @ 821:a17888ed66a8 trunk
[svn] - safety checks
author | nenolod |
---|---|
date | Sat, 11 Mar 2006 21:06:47 -0800 |
parents | 86ca43d8a845 |
children | f12d7e208b43 |
comparison
equal
deleted
inserted
replaced
820:4e6132a6c2c1 | 821:a17888ed66a8 |
---|---|
56 gint | 56 gint |
57 vfs_fclose(VFSFile * file) | 57 vfs_fclose(VFSFile * file) |
58 { | 58 { |
59 gint ret = 0; | 59 gint ret = 0; |
60 | 60 |
61 if (file == NULL) | |
62 return -1; | |
63 | |
61 if (file->handle) { | 64 if (file->handle) { |
62 if (fclose(file->handle) != 0) | 65 if (fclose(file->handle) != 0) |
63 ret = -1; | 66 ret = -1; |
64 } | 67 } |
65 | 68 |
72 vfs_fread(gpointer ptr, | 75 vfs_fread(gpointer ptr, |
73 size_t size, | 76 size_t size, |
74 size_t nmemb, | 77 size_t nmemb, |
75 VFSFile * file) | 78 VFSFile * file) |
76 { | 79 { |
80 if (file == NULL) | |
81 return 0; | |
82 | |
77 return fread(ptr, size, nmemb, file->handle); | 83 return fread(ptr, size, nmemb, file->handle); |
78 } | 84 } |
79 | 85 |
80 size_t | 86 size_t |
81 vfs_fwrite(gconstpointer ptr, | 87 vfs_fwrite(gconstpointer ptr, |
82 size_t size, | 88 size_t size, |
83 size_t nmemb, | 89 size_t nmemb, |
84 VFSFile * file) | 90 VFSFile * file) |
85 { | 91 { |
92 if (file == NULL) | |
93 return 0; | |
94 | |
86 return fwrite(ptr, size, nmemb, file->handle); | 95 return fwrite(ptr, size, nmemb, file->handle); |
87 } | 96 } |
88 | 97 |
89 gint | 98 gint |
90 vfs_fseek(VFSFile * file, | 99 vfs_fseek(VFSFile * file, |
91 glong offset, | 100 glong offset, |
92 gint whence) | 101 gint whence) |
93 { | 102 { |
103 if (file == NULL) | |
104 return 0; | |
105 | |
94 return fseek(file->handle, offset, whence); | 106 return fseek(file->handle, offset, whence); |
95 } | 107 } |
96 | 108 |
97 void | 109 void |
98 vfs_rewind(VFSFile * file) | 110 vfs_rewind(VFSFile * file) |
99 { | 111 { |
112 if (file == NULL) | |
113 return; | |
114 | |
100 rewind(file->handle); | 115 rewind(file->handle); |
101 } | 116 } |
102 | 117 |
103 glong | 118 glong |
104 vfs_ftell(VFSFile * file) | 119 vfs_ftell(VFSFile * file) |
105 { | 120 { |
121 if (file == NULL) | |
122 return 0; | |
123 | |
106 return ftell(file->handle); | 124 return ftell(file->handle); |
107 } | 125 } |
108 | 126 |
109 gboolean | 127 gboolean |
110 vfs_feof(VFSFile * file) | 128 vfs_feof(VFSFile * file) |
111 { | 129 { |
112 return (gboolean)feof(file->handle); | 130 if (file == NULL) |
131 return FALSE; | |
132 | |
133 return (gboolean) feof(file->handle); | |
113 } | 134 } |
114 | 135 |
115 gboolean | 136 gboolean |
116 vfs_file_test(const gchar * path, GFileTest test) | 137 vfs_file_test(const gchar * path, GFileTest test) |
117 { | 138 { |
131 } | 152 } |
132 | 153 |
133 gint | 154 gint |
134 vfs_truncate(VFSFile * file, glong size) | 155 vfs_truncate(VFSFile * file, glong size) |
135 { | 156 { |
157 if (file == NULL) | |
158 return -1; | |
159 | |
136 return ftruncate(fileno(file->handle), size); | 160 return ftruncate(fileno(file->handle), size); |
137 } | 161 } |