Skip to content

Commit 933587b

Browse files
author
Oleh Kulykov
committed
1722293355
1 parent 7d5f8ba commit 933587b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/plzma_file_utils.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
namespace plzma {
3333
namespace fileUtils {
3434

35+
#define LIBPLZMA_FILEUTILS_FILE_ERASE_BUFFSIZE 262144
36+
3537
bool fileErase(const Path & path, const plzma_erase eraseType) {
3638
if (eraseType == plzma_erase_zero) {
37-
const size_t buffSize = 256 * 1024;
38-
uint8_t buff[buffSize];
39+
const size_t buffSize = LIBPLZMA_FILEUTILS_FILE_ERASE_BUFFSIZE;
40+
uint8_t buff[LIBPLZMA_FILEUTILS_FILE_ERASE_BUFFSIZE];
3941
::memset(buff, 0, buffSize);
4042
// "r+" | read/update: Open a file for update (both for input and output). The file must exist.
4143
FILE * f = path.openFile("r+b");
@@ -54,7 +56,7 @@ namespace fileUtils {
5456
}
5557

5658
if (size > 0) {
57-
for (uint64_t i = 0, n = static_cast<uint64_t>(size) / buffSize; i < n; i++) {
59+
for (uint64_t i = 0, n = static_cast<uint64_t>(size) / static_cast<uint64_t>(buffSize); i < n; i++) {
5860
const size_t w = ::fwrite(buff, 1, buffSize, f);
5961
if (w != buffSize) {
6062
::fclose(f);

src/plzma_file_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace fileUtils {
5151
}
5252

5353
inline int64_t fileTell(FILE * LIBPLZMA_NONNULL file) noexcept {
54-
#if defined(LIBPLZMA_MSC)
54+
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
5555
return _ftelli64(file);
5656
#elif defined(LIBPLZMA_POSIX)
5757
return ftello(file);

0 commit comments

Comments
 (0)