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