-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
63 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,12 @@ | |
* @license This project is released under the Apache License. | ||
* @author XUranus([email protected]) | ||
*/ | ||
#ifdef __linux__ | ||
|
||
#ifndef VOLUMEBACKUP_DM_DEVICE_MAPPER_CONTROL_H | ||
#define VOLUMEBACKUP_DM_DEVICE_MAPPER_CONTROL_H | ||
|
||
#ifdef __linux__ | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,13 @@ | |
* @author XUranus([email protected]) | ||
*/ | ||
|
||
#ifdef __linux__ | ||
|
||
#ifndef VOLUMEBACKUP_NATIVE_POSIX_RAW_IO_HEADER | ||
#define VOLUMEBACKUP_NATIVE_POSIX_RAW_IO_HEADER | ||
|
||
#include "VolumeProtectMacros.h" | ||
#include "common/VolumeProtectMacros.h" | ||
|
||
#ifdef POSIXAPI | ||
|
||
#include "RawIO.h" | ||
|
||
// Raw I/O Reader/Writer for *unix platform posix API implementation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,27 +4,29 @@ | |
* @author XUranus([email protected]) | ||
*/ | ||
|
||
#include "common/VolumeProtectMacros.h" | ||
|
||
#include <cerrno> | ||
#include <cstdio> | ||
|
||
#ifdef __linux__ | ||
#include <sys/mount.h> | ||
#include <mntent.h> | ||
|
||
#ifdef POSIXAPI | ||
#include <fcntl.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <linux/fs.h> | ||
#include <unistd.h> | ||
#include <dirent.h> | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
#ifdef __linux__ | ||
#include <sys/mount.h> | ||
#include <mntent.h> | ||
#include <linux/fs.h> | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
#include <locale> | ||
#include <codecvt> | ||
|
||
#ifndef WIN32_LEAN_AND_MEAN | ||
#define WIN32_LEAN_AND_MEAN | ||
#endif | ||
|
@@ -97,7 +99,7 @@ const char* SystemApiException::what() const noexcept | |
|
||
bool fsapi::IsFileExists(const std::string& path) | ||
{ | ||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
struct stat st; | ||
return ::stat(path.c_str(), &st) == 0; | ||
#endif | ||
|
@@ -110,7 +112,7 @@ bool fsapi::IsFileExists(const std::string& path) | |
|
||
uint64_t fsapi::GetFileSize(const std::string& path) | ||
{ | ||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
struct stat st; | ||
return ::stat(path.c_str(), &st) == 0 ? st.st_size : 0; | ||
#endif | ||
|
@@ -137,7 +139,8 @@ bool fsapi::IsDirectoryExists(const std::string& path) | |
return true; | ||
} | ||
return ::CreateDirectoryW(wpath.c_str(), nullptr) != 0; | ||
#else | ||
#endif | ||
#ifdef POSIXAPI | ||
DIR* dir = ::opendir(path.c_str()); | ||
if (dir) { | ||
closedir(dir); | ||
|
@@ -305,7 +308,7 @@ bool fsapi::IsVolumeExists(const std::string& volumePath) | |
bool fsapi::CreateEmptyFile(const std::string& dirPath, const std::string& filename) | ||
{ | ||
std::string fullpath = dirPath + SEPARATOR + filename; | ||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
int fd = ::open(fullpath.c_str(), O_CREAT | O_WRONLY, 0644); | ||
if (fd == -1) { | ||
return false; | ||
|
@@ -333,7 +336,7 @@ bool fsapi::CreateEmptyFile(const std::string& dirPath, const std::string& filen | |
bool fsapi::RemoveFile(const std::string& dirPath, const std::string& filename) | ||
{ | ||
std::string fullpath = dirPath + SEPARATOR + filename; | ||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
if (::access(fullpath.c_str(), F_OK) == 0 && ::unlink(fullpath.c_str()) < 0) { | ||
return false; | ||
} | ||
|
@@ -346,7 +349,7 @@ bool fsapi::RemoveFile(const std::string& dirPath, const std::string& filename) | |
|
||
uint32_t fsapi::ProcessorsNum() | ||
{ | ||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
auto processorCount = sysconf(_SC_NPROCESSORS_ONLN); | ||
return processorCount <= 0 ? DEFAULT_PROCESSORS_NUM : processorCount; | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* @author XUranus([email protected]) | ||
*/ | ||
|
||
#include "common/VolumeProtectMacros.h" | ||
#include "VolumeProtector.h" | ||
#include <cerrno> | ||
#include <cstdint> | ||
|
@@ -23,7 +24,7 @@ using OsPlatformRawDataReader = rawio::win32::Win32RawDataReader; | |
using OsPlatformRawDataWriter = rawio::win32::Win32RawDataWriter; | ||
#endif | ||
|
||
#ifdef __linux__ | ||
#ifdef POSIXAPI | ||
#include "linux/PosixRawIO.h" | ||
using OsPlatformRawDataReader = rawio::posix::PosixRawDataReader; | ||
using OsPlatformRawDataWriter = rawio::posix::PosixRawDataWriter; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,16 @@ | |
* @author XUranus([email protected]) | ||
*/ | ||
|
||
#ifdef __linux__ | ||
#include "common/VolumeProtectMacros.h" | ||
|
||
#ifdef POSIXAPI | ||
|
||
#include <cerrno> | ||
#include <cstdio> | ||
#include <fcntl.h> | ||
#include <sys/ioctl.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <linux/fs.h> | ||
#include <unistd.h> | ||
#include <dirent.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters