OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/fxcrt/fx_ext.h" | 7 #include "../../include/fxcrt/fx_ext.h" |
8 #include "fxcrt_platforms.h" | 8 #include "fxcrt_platforms.h" |
9 #if (_FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ && _FXM_PLATFORM_ != _FXM_PLATFORM
_LINUX_ && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ && _FXM_PLATFORM_ != _FXM_PLAT
FORM_ANDROID_) | 9 #if (_FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ && _FXM_PLATFORM_ != _FXM_PLATFORM
_LINUX_ && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ && _FXM_PLATFORM_ != _FXM_PLAT
FORM_ANDROID_) |
10 IFXCRT_FileAccess* FXCRT_FileAccess_Create() | 10 IFXCRT_FileAccess* FXCRT_FileAccess_Create() |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 FX_FILESIZE size = src.GetSize(); | 163 FX_FILESIZE size = src.GetSize(); |
164 if (!size) { | 164 if (!size) { |
165 return FALSE; | 165 return FALSE; |
166 } | 166 } |
167 if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { | 167 if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { |
168 return FALSE; | 168 return FALSE; |
169 } | 169 } |
170 FX_FILESIZE num = 0; | 170 FX_FILESIZE num = 0; |
171 FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768); | 171 FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768); |
172 if (!pBuffer) { | |
173 return FALSE; | |
174 } | |
175 while (num = src.Read(pBuffer, 32768)) { | 172 while (num = src.Read(pBuffer, 32768)) { |
176 if (dst.Write(pBuffer, num) != num) { | 173 if (dst.Write(pBuffer, num) != num) { |
177 break; | 174 break; |
178 } | 175 } |
179 } | 176 } |
180 FX_Free(pBuffer); | 177 FX_Free(pBuffer); |
181 return TRUE; | 178 return TRUE; |
182 } | 179 } |
183 FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst) | 180 FX_BOOL FX_File_Copy(FX_WSTR fileNameSrc, FX_WSTR fileNameDst) |
184 { | 181 { |
185 return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); | 182 return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); |
186 } | 183 } |
187 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst) | 184 FX_BOOL FX_File_Move(FX_BSTR fileNameSrc, FX_BSTR fileNameDst) |
188 { | 185 { |
189 return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); | 186 return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); |
190 } | 187 } |
191 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst) | 188 FX_BOOL FX_File_Move(FX_WSTR fileNameSrc, FX_WSTR fileNameDst) |
192 { | 189 { |
193 return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); | 190 return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); |
194 } | 191 } |
195 #endif | 192 #endif |
OLD | NEW |