mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Add base::file_size() function
This commit is contained in:
parent
483878140a
commit
e8d4388061
@ -15,6 +15,8 @@ namespace base {
|
||||
bool is_file(const std::string& path);
|
||||
bool is_directory(const std::string& path);
|
||||
|
||||
size_t file_size(const std::string& path);
|
||||
|
||||
void delete_file(const std::string& path);
|
||||
|
||||
bool has_readonly_attr(const std::string& path);
|
||||
|
@ -42,6 +42,12 @@ void make_directory(const std::string& path)
|
||||
}
|
||||
}
|
||||
|
||||
size_t file_size(const std::string& path)
|
||||
{
|
||||
struct stat sts;
|
||||
return (stat(path.c_str(), &sts) == 0) ? sts.st_size: 0;
|
||||
}
|
||||
|
||||
void delete_file(const std::string& path)
|
||||
{
|
||||
int result = unlink(path.c_str());
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include <windows.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "base/string.h"
|
||||
#include "base/win32_exception.h"
|
||||
@ -30,6 +31,12 @@ bool is_directory(const std::string& path)
|
||||
((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
size_t file_size(const std::string& path)
|
||||
{
|
||||
struct _stat sts;
|
||||
return (_wstat(from_utf8(path).c_str(), &sts) == 0) ? sts.st_size: 0;
|
||||
}
|
||||
|
||||
void delete_file(const std::string& path)
|
||||
{
|
||||
BOOL result = ::DeleteFile(from_utf8(path).c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user