Replace deprecated LLVM functions.

Several functions regarding file handling are deprecated. This commit replaces these functions with the new one from llvm::sys::fs and llvm::sys::path. It also removes some warnings about signed/unsigned mismatches.
This commit is contained in:
kai
2011-11-16 19:05:23 +01:00
parent 7431d58702
commit 1ecd536f45
2 changed files with 28 additions and 23 deletions

View File

@@ -3,6 +3,7 @@
#include <cassert>
#include <cstring>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "libconfig.h++"
@@ -31,7 +32,7 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
// try the current working dir
p = sys::Path::GetCurrentDirectory();
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
// user configuration
@@ -40,14 +41,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
p = sys::Path::GetUserHomeDirectory();
p.appendComponent(".ldc");
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
#if _WIN32
// try home dir
p = sys::Path::GetUserHomeDirectory();
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
#endif
@@ -57,14 +58,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
// try the install-prefix
p = sys::Path(LDC_INSTALL_PREFIX);
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
#else
// try the install-prefix/etc
p = sys::Path(LDC_INSTALL_PREFIX);
p.appendComponent("etc");
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
// try the install-prefix/etc/ldc
@@ -72,19 +73,19 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
p.appendComponent("etc");
p.appendComponent("ldc");
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
// try /etc (absolute path)
p = sys::Path("/etc");
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
// try /etc/ldc (absolute path)
p = sys::Path("/etc/ldc");
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
#endif
@@ -92,7 +93,7 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
p = sys::Path::GetMainExecutable(argv0, mainAddr);
p.eraseComponent();
p.appendComponent(filename);
if (p.exists())
if (sys::fs::exists(p.str()))
return true;
return false;
@@ -134,7 +135,7 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename)
{
std::string binpathkey = "%%ldcbinarypath%%";
std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname();
std::string binpath = sys::path::parent_path(sys::Path::GetMainExecutable(argv0, mainAddr).str());
libconfig::Setting& arr = cfg->lookup("default.switches");
int len = arr.getLength();