提交 1c83ea8c 编写于 作者: C chengtbf 提交者: Will Zhang

fix Windows for DeleteFile macro and Socket lib (#359)



Former-commit-id: a07174d7
上级 fbcd7d5a
......@@ -40,6 +40,7 @@ set(oneflow_third_party_libs
if(WIN32)
# static gflags lib requires "PathMatchSpecA" defined in "ShLwApi.Lib"
list(APPEND oneflow_third_party_libs "ShLwApi.Lib")
list(APPEND oneflow_third_party_libs "Ws2_32.lib")
endif()
set(oneflow_third_party_dependencies
......
......@@ -45,7 +45,7 @@ void FileSystem::RecursivelyDeleteDir(const std::string& dirname) {
} else {
// Delete file might fail because of permissions issues or might be
// unimplemented.
DeleteFile(child_path);
DelFile(child_path);
}
}
}
......
......@@ -4,10 +4,6 @@
#include "oneflow/core/common/util.h"
#include "oneflow/core/persistence/platform.h"
#if defined(_WIN32)
#undef DeleteFile
#endif
namespace oneflow {
namespace fs {
......@@ -114,7 +110,8 @@ class FileSystem {
virtual std::vector<std::string> ListDir(const std::string& dir) = 0;
// Deletes the named file.
virtual void DeleteFile(const std::string& fname) = 0;
// Using DelFile to avoid Windows macro
virtual void DelFile(const std::string& fname) = 0;
// Creates the specified directory.
virtual void CreateDir(const std::string& dirname) = 0;
......
......@@ -330,7 +330,7 @@ std::vector<std::string> HadoopFileSystem::ListDir(const std::string& dir) {
return result;
}
void HadoopFileSystem::DeleteFile(const std::string& fname) {
void HadoopFileSystem::DelFile(const std::string& fname) {
hdfsFS fs = nullptr;
CHECK(Connect(&fs));
PCHECK(hdfs_->hdfsDelete(fs, TranslateName(fname).c_str(), /*recursive=*/0)
......
......@@ -78,7 +78,7 @@ class HadoopFileSystem final : public FileSystem {
std::vector<std::string> ListDir(const std::string& dir) override;
void DeleteFile(const std::string& fname) override;
void DelFile(const std::string& fname) override;
void CreateDir(const std::string& dirname) override;
......
......@@ -125,7 +125,7 @@ std::vector<std::string> PosixFileSystem::ListDir(const std::string& dir) {
return result;
}
void PosixFileSystem::DeleteFile(const std::string& fname) {
void PosixFileSystem::DelFile(const std::string& fname) {
PCHECK(unlink(TranslateName(fname).c_str()) == 0)
<< "Fail to delete file " << fname;
}
......
......@@ -28,7 +28,7 @@ class PosixFileSystem final : public FileSystem {
std::vector<std::string> ListDir(const std::string& dir) override;
void DeleteFile(const std::string& fname) override;
void DelFile(const std::string& fname) override;
void CreateDir(const std::string& dirname) override;
......
......@@ -70,7 +70,7 @@ void Snapshot::ConcatLbnFile(const std::string& lbn, int32_t part_num,
out_stream.Write(buffer, n);
offset += n;
}
GlobalFS()->DeleteFile(part_file_path);
GlobalFS()->DelFile(part_file_path);
}
}
GlobalFS()->DeleteDir(part_dir);
......
......@@ -222,7 +222,7 @@ std::vector<std::string> WindowsFileSystem::ListDir(const std::string& dir) {
return result;
}
void WindowsFileSystem::DeleteFile(const std::string& fname) {
void WindowsFileSystem::DelFile(const std::string& fname) {
std::wstring file_name = Utf8ToWideChar(fname);
PCHECK(_wunlink(file_name.c_str()) == 0)
<< "Failed to delete a file: " + fname;
......
......@@ -7,8 +7,6 @@
#include <Windows.h>
#undef DeleteFile
namespace oneflow {
namespace fs {
......@@ -32,7 +30,7 @@ class WindowsFileSystem final : public FileSystem {
std::vector<std::string> ListDir(const std::string& dir) override;
void DeleteFile(const std::string& fname) override;
void DelFile(const std::string& fname) override;
void CreateDir(const std::string& dirname) override;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册