authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-06-15 22:21:01+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-06-15 22:21:01+03:00
log2c8a3aaf855475cabef4e8275581a12b06417a02
treeddea504e9125e606ebb664a4bc5871203695e1b9
parent242246f79312f3106290b9b1aea6dfd5a18368b0

Use _wfopen instead of fopen on windows


1 files changed, 25 insertions(+), 0 deletions(-)

src/os.cpp+25
......@@ -1037,7 +1037,12 @@ Error os_exec_process(ZigList<const char *> &args,
10371037}
10381038
10391039Error os_write_file(Buf *full_path, Buf *contents) {
1040#if defined(ZIG_OS_WINDOWS)
1041 PathSpace path_space = slice_to_prefixed_file_w(buf_to_slice(full_path));
1042 FILE *f = _wfopen(&path_space.data.items[0], L"wb");
1043#else
10401044 FILE *f = fopen(buf_ptr(full_path), "wb");
1045#endif
10411046 if (!f) {
10421047 zig_panic("os_write_file failed for %s", buf_ptr(full_path));
10431048 }
......@@ -1072,7 +1077,12 @@ static Error copy_open_files(FILE *src_f, FILE *dest_f) {
10721077Error os_dump_file(Buf *src_path, FILE *dest_file) {
10731078 Error err;
10741079
1080#if defined(ZIG_OS_WINDOWS)
1081 PathSpace path_space = slice_to_prefixed_file_w(buf_to_slice(src_path));
1082 FILE *src_f = _wfopen(&path_space.data.items[0], L"rb");
1083#else
10751084 FILE *src_f = fopen(buf_ptr(src_path), "rb");
1085#endif
10761086 if (!src_f) {
10771087 int err = errno;
10781088 if (err == ENOENT) {
......@@ -1189,7 +1199,12 @@ Error os_update_file(Buf *src_path, Buf *dst_path) {
11891199}
11901200
11911201Error os_copy_file(Buf *src_path, Buf *dest_path) {
1202#if defined(ZIG_OS_WINDOWS)
1203 PathSpace src_path_space = slice_to_prefixed_file_w(buf_to_slice(src_path));
1204 FILE *src_f = _wfopen(&src_path_space.data.items[0], L"rb");
1205#else
11921206 FILE *src_f = fopen(buf_ptr(src_path), "rb");
1207#endif
11931208 if (!src_f) {
11941209 int err = errno;
11951210 if (err == ENOENT) {
......@@ -1200,7 +1215,12 @@ Error os_copy_file(Buf *src_path, Buf *dest_path) {
12001215 return ErrorFileSystem;
12011216 }
12021217 }
1218#if defined(ZIG_OS_WINDOWS)
1219 PathSpace dest_path_space = slice_to_prefixed_file_w(buf_to_slice(dest_path));
1220 FILE *dest_f = _wfopen(&dest_path_space.data.items[0], L"wb");
1221#else
12031222 FILE *dest_f = fopen(buf_ptr(dest_path), "wb");
1223#endif
12041224 if (!dest_f) {
12051225 int err = errno;
12061226 if (err == ENOENT) {
......@@ -1221,7 +1241,12 @@ Error os_copy_file(Buf *src_path, Buf *dest_path) {
12211241}
12221242
12231243Error os_fetch_file_path(Buf *full_path, Buf *out_contents) {
1244#if defined(ZIG_OS_WINDOWS)
1245 PathSpace path_space = slice_to_prefixed_file_w(buf_to_slice(full_path));
1246 FILE *f = _wfopen(&path_space.data.items[0], L"rb");
1247#else
12241248 FILE *f = fopen(buf_ptr(full_path), "rb");
1249#endif
12251250 if (!f) {
12261251 switch (errno) {
12271252 case EACCES: