aboutsummaryrefslogtreecommitdiff
path: root/lib/io/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'lib/io/src/win32')
-rw-r--r--lib/io/src/win32/istream.c15
-rw-r--r--lib/io/src/win32/ostream.c28
2 files changed, 6 insertions, 37 deletions
diff --git a/lib/io/src/win32/istream.c b/lib/io/src/win32/istream.c
index e6cb266..7cc7144 100644
--- a/lib/io/src/win32/istream.c
+++ b/lib/io/src/win32/istream.c
@@ -154,25 +154,14 @@ fail_free:
sqfs_istream_t *istream_open_file(const char *path)
{
- WCHAR *wpath = NULL;
+ sqfs_file_handle_t hnd;
sqfs_istream_t *out;
- HANDLE hnd;
-
- wpath = path_to_windows(path);
- if (wpath == NULL)
- return NULL;
- hnd = CreateFileW(wpath, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
- if (hnd == INVALID_HANDLE_VALUE) {
+ if (sqfs_open_native_file(&hnd, path, SQFS_FILE_OPEN_READ_ONLY)) {
w32_perror(path);
- free(wpath);
return NULL;
}
- free(wpath);
-
out = istream_open_handle(path, hnd);
if (out == NULL)
CloseHandle(hnd);
diff --git a/lib/io/src/win32/ostream.c b/lib/io/src/win32/ostream.c
index 5b099a4..5b584e5 100644
--- a/lib/io/src/win32/ostream.c
+++ b/lib/io/src/win32/ostream.c
@@ -176,39 +176,19 @@ fail_free:
sqfs_ostream_t *ostream_open_file(const char *path, int flags)
{
- int access_flags, creation_mode;
- WCHAR *wpath = NULL;
+ sqfs_file_handle_t hnd;
sqfs_ostream_t *out;
- HANDLE hnd;
-
- access_flags = GENERIC_WRITE;
-
- if (flags & SQFS_FILE_OPEN_OVERWRITE) {
- creation_mode = CREATE_ALWAYS;
- } else {
- creation_mode = CREATE_NEW;
- }
- if (flags & SQFS_FILE_OPEN_NO_CHARSET_XFRM) {
- hnd = CreateFileA(path, access_flags, 0, NULL, creation_mode,
- FILE_ATTRIBUTE_NORMAL, NULL);
- } else {
- wpath = path_to_windows(path);
- if (wpath == NULL)
- return NULL;
-
- hnd = CreateFileW(wpath, access_flags, 0, NULL, creation_mode,
- FILE_ATTRIBUTE_NORMAL, NULL);
+ if (sqfs_open_native_file(&hnd, path, flags)) {
+ w32_perror(path);
+ return NULL;
}
if (hnd == INVALID_HANDLE_VALUE) {
w32_perror(path);
- free(wpath);
return NULL;
}
- free(wpath);
-
out = ostream_open_handle(path, hnd, flags);
if (out == NULL)
CloseHandle(hnd);