Add files which were missed in r6278
Originally committed to SVN as r6283.
This commit is contained in:
parent
4ab04b79dd
commit
5774e87248
3 changed files with 19 additions and 18 deletions
|
@ -18,6 +18,10 @@
|
||||||
/// @brief Unix access methods.
|
/// @brief Unix access methods.
|
||||||
/// @ingroup libaegisub unix
|
/// @ingroup libaegisub unix
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "libaegisub/access.h"
|
||||||
|
|
||||||
#ifndef LAGI_PRE
|
#ifndef LAGI_PRE
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -88,20 +92,14 @@ void Check(const std::string &file, acs::Type type) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
file_status = access(file.c_str(), R_OK);
|
||||||
case DirRead:
|
if (file_status != 0)
|
||||||
case FileRead:
|
throw Read("File or directory is not readable.");
|
||||||
file_status = access(file.c_str(), R_OK);
|
|
||||||
if (file_status != 0)
|
|
||||||
throw Read("File or directory is not readable.");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DirWrite:
|
if (type == DirWrite || type == FileWrite) {
|
||||||
case FileWrite:
|
file_status = access(file.c_str(), W_OK);
|
||||||
file_status = access(file.c_str(), W_OK);
|
if (file_status != 0)
|
||||||
if (file_status != 0)
|
throw Write("File or directory is not writable.");
|
||||||
throw Write("File or directory is not writable.");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "libaegisub/io.h"
|
||||||
|
|
||||||
#ifndef LAGI_PRE
|
#ifndef LAGI_PRE
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -28,7 +30,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libaegisub/io.h"
|
#include "libaegisub/access.h"
|
||||||
#include "libaegisub/log.h"
|
#include "libaegisub/log.h"
|
||||||
#include "libaegisub/util.h"
|
#include "libaegisub/util.h"
|
||||||
|
|
||||||
|
@ -57,12 +59,11 @@ Save::Save(const std::string& file, bool binary): file_name(file) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
acs::CheckFileWrite(file);
|
acs::CheckFileWrite(file);
|
||||||
} catch (acs::AcsNotFound& e) {
|
} catch (FileNotFoundError const&) {
|
||||||
// If the file doesn't exist we create a 0 byte file, this so so
|
// If the file doesn't exist we create a 0 byte file, this so so
|
||||||
// util::Rename will find it, and to let users know something went
|
// util::Rename will find it, and to let users know something went
|
||||||
// wrong by leaving a 0 byte file.
|
// wrong by leaving a 0 byte file.
|
||||||
std::ofstream fp_touch(file.c_str());
|
std::ofstream(file.c_str());
|
||||||
fp_touch.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @todo This is a temp hack, proper implementation needs to come after
|
/// @todo This is a temp hack, proper implementation needs to come after
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "libaegisub/util.h"
|
#include "libaegisub/util.h"
|
||||||
|
|
||||||
|
#include "libaegisub/access.h"
|
||||||
|
|
||||||
#ifndef LAGI_PRE
|
#ifndef LAGI_PRE
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -55,7 +57,7 @@ void Rename(const std::string& from, const std::string& to) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
acs::CheckFileWrite(to);
|
acs::CheckFileWrite(to);
|
||||||
} catch (acs::AcsNotFound& e) {
|
} catch (FileNotFoundError const&) {
|
||||||
acs::CheckDirWrite(DirName(to));
|
acs::CheckDirWrite(DirName(to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue