Rename base::file/directory_exists() to base::is_file/directory()

This commit is contained in:
David Capello 2014-04-17 17:12:55 -03:00
parent 138d2f1db8
commit 2e9751fef1
14 changed files with 19 additions and 19 deletions

View File

@ -142,7 +142,7 @@ protected:
// Ask if the user wants overwrite the existent file.
int ret = 0;
if (base::file_exists(filename)) {
if (base::is_file(filename)) {
ret = ui::Alert::show("Warning<<The file already exists, overwrite it?<<%s||&Yes||&No||&Cancel",
base::get_file_name(filename).c_str());

View File

@ -57,7 +57,7 @@ void SavePaletteCommand::onExecute(Context* context)
again:
filename = app::show_file_selector("Save Palette", "", "png,pcx,bmp,tga,col,gpl");
if (!filename.empty()) {
if (base::file_exists(filename)) {
if (base::is_file(filename)) {
ret = Alert::show("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel",
base::get_file_name(filename).c_str());

View File

@ -41,7 +41,7 @@ DataRecovery::DataRecovery(Context* context)
// Check if there is already data to recover
const base::string existent_data_path = get_config_string("DataRecovery", "Path", "");
if (!existent_data_path.empty() &&
base::directory_exists(existent_data_path)) {
base::is_directory(existent_data_path)) {
// Load the backup data.
m_tempDir = new base::TempDir();
m_tempDir->attach(existent_data_path);

View File

@ -152,7 +152,7 @@ FileOp* fop_to_load_document(const char* filename, int flags)
PRINTF("Loading file \"%s\" (%s)\n", filename, extension.c_str());
// Does file exist?
if (!base::file_exists(filename)) {
if (!base::is_file(filename)) {
fop_error(fop, "File not found: \"%s\"\n", filename);
goto done;
}

View File

@ -76,7 +76,7 @@ std::string PalettesLoader::palettesLocation()
ResourceFinder rf;
rf.includeDataDir("palettes");
while (rf.next()) {
if (base::directory_exists(rf.filename())) {
if (base::is_directory(rf.filename())) {
path = rf.filename();
break;
}

View File

@ -43,7 +43,7 @@ RecentFiles::RecentFiles()
sprintf(buf, "Filename%02d", c);
const char* filename = get_config_string("RecentFiles", buf, NULL);
if (filename && *filename && base::file_exists(filename))
if (filename && *filename && base::is_file(filename))
m_files.addItem(filename);
}

View File

@ -57,7 +57,7 @@ bool ResourceFinder::findFirst()
while (next()) {
PRINTF("Loading resource from \"%s\"...\n", filename().c_str());
if (base::file_exists(filename())) {
if (base::is_file(filename())) {
PRINTF("- OK\n");
return true;
}

View File

@ -42,7 +42,7 @@ WebServer::WebServer()
rf.includeDataDir("www");
while (rf.next()) {
if (base::directory_exists(rf.filename())) {
if (base::is_directory(rf.filename())) {
m_wwwpath = rf.filename();
break;
}
@ -78,7 +78,7 @@ void WebServer::onProcessRequest(webserver::IRequest* request,
uri = "/index.html";
std::string fn = base::join_path(m_wwwpath, uri);
if (base::file_exists(fn)) {
if (base::is_file(fn)) {
response->sendFile(fn.c_str());
}
else {

View File

@ -28,7 +28,7 @@ TEST(FileHandle, Descriptors)
// Delete the file if it exists.
ASSERT_NO_THROW({
if (file_exists(fn))
if (is_file(fn))
delete_file(fn);
});

View File

@ -12,8 +12,8 @@
namespace base {
bool file_exists(const string& path);
bool directory_exists(const string& path);
bool is_file(const string& path);
bool is_directory(const string& path);
void delete_file(const string& path);

View File

@ -21,13 +21,13 @@
namespace base {
bool file_exists(const string& path)
bool is_file(const string& path)
{
struct stat sts;
return (stat(path.c_str(), &sts) == 0 && S_ISREG(sts.st_mode)) ? true: false;
}
bool directory_exists(const string& path)
bool is_directory(const string& path)
{
struct stat sts;
return (stat(path.c_str(), &sts) == 0 && S_ISDIR(sts.st_mode)) ? true: false;

View File

@ -12,7 +12,7 @@
namespace base {
bool file_exists(const string& path)
bool is_file(const string& path)
{
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());
@ -22,7 +22,7 @@ bool file_exists(const string& path)
!(attr & FILE_ATTRIBUTE_DIRECTORY));
}
bool directory_exists(const string& path)
bool is_directory(const string& path)
{
DWORD attr = ::GetFileAttributes(from_utf8(path).c_str());

View File

@ -92,7 +92,7 @@ bool open_folder(const std::string& file)
{
#ifdef WIN32
int ret;
if (base::directory_exists(file)) {
if (base::is_directory(file)) {
ret = win32_shell_execute(NULL, L"explorer",
(L"/n,/e,\"" + base::from_utf8(file) + L"\"").c_str());
}

View File

@ -28,7 +28,7 @@ TempDir::TempDir(const string& appName)
m_path = join_path(get_temp_path(),
appName + convert_to<string>(i));
if (!directory_exists(m_path)) {
if (!is_directory(m_path)) {
make_directory(m_path);
break;
}
@ -57,7 +57,7 @@ void TempDir::attach(const string& path)
{
remove();
ASSERT(directory_exists(path));
ASSERT(is_directory(path));
m_path = path;
}