mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
fixed access() assert when using msvc 8.0 runtime
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@20 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
a8a120ed83
commit
a083be01aa
2 changed files with 11 additions and 1 deletions
|
@ -477,6 +477,7 @@ const char* file_dialog(GtkWidget* parent, bool open, const char* title, const c
|
||||||
file_dialog_show(parent, open, title, path, pattern);
|
file_dialog_show(parent, open, title, path, pattern);
|
||||||
|
|
||||||
if(open
|
if(open
|
||||||
|
|| file == 0
|
||||||
|| !file_exists(file)
|
|| !file_exists(file)
|
||||||
|| gtk_MessageBox(parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION) == eIDYES)
|
|| gtk_MessageBox(parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION) == eIDYES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,10 +27,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#if defined( WIN32 )
|
#if defined( WIN32 )
|
||||||
#define S_ISDIR(mode) (mode & _S_IFDIR)
|
#define S_ISDIR(mode) (mode & _S_IFDIR)
|
||||||
#include <io.h> // access()
|
#include <io.h> // _access()
|
||||||
#define F_OK 0x00
|
#define F_OK 0x00
|
||||||
#define W_OK 0x02
|
#define W_OK 0x02
|
||||||
#define R_OK 0x04
|
#define R_OK 0x04
|
||||||
|
#define access(path, mode) _access(path, mode)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h> // access()
|
#include <unistd.h> // access()
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,6 +42,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
#include "debugging/debugging.h"
|
||||||
|
|
||||||
/// \brief Attempts to move the file identified by \p from to \p to and returns true if the operation was successful.
|
/// \brief Attempts to move the file identified by \p from to \p to and returns true if the operation was successful.
|
||||||
///
|
///
|
||||||
/// The operation will fail unless:
|
/// The operation will fail unless:
|
||||||
|
@ -50,6 +53,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
/// - The directory component of \p to identifies an existing directory which is accessible for writing.
|
/// - The directory component of \p to identifies an existing directory which is accessible for writing.
|
||||||
inline bool file_move(const char* from, const char* to)
|
inline bool file_move(const char* from, const char* to)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(from != 0 && to != 0, "file_move: invalid path");
|
||||||
return rename(from, to) == 0;
|
return rename(from, to) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +64,7 @@ inline bool file_move(const char* from, const char* to)
|
||||||
/// - The parent-directory component of \p path identifies an existing directory which is accessible for writing.
|
/// - The parent-directory component of \p path identifies an existing directory which is accessible for writing.
|
||||||
inline bool file_remove(const char* path)
|
inline bool file_remove(const char* path)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(path != 0, "file_remove: invalid path");
|
||||||
return remove(path) == 0;
|
return remove(path) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +82,7 @@ namespace FileAccess
|
||||||
/// \brief Returns true if the file or directory identified by \p path exists and/or may be accessed for reading, writing or both, depending on the value of \p mode.
|
/// \brief Returns true if the file or directory identified by \p path exists and/or may be accessed for reading, writing or both, depending on the value of \p mode.
|
||||||
inline bool file_accessible(const char* path, FileAccess::Mode mode)
|
inline bool file_accessible(const char* path, FileAccess::Mode mode)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(path != 0, "file_accessible: invalid path");
|
||||||
return access(path, static_cast<int>(mode)) == 0;
|
return access(path, static_cast<int>(mode)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +107,7 @@ inline bool file_exists(const char* path)
|
||||||
/// \brief Returns true if the file or directory identified by \p path exists and is a directory.
|
/// \brief Returns true if the file or directory identified by \p path exists and is a directory.
|
||||||
inline bool file_is_directory(const char* path)
|
inline bool file_is_directory(const char* path)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(path != 0, "file_is_directory: invalid path");
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(stat(path, &st) == -1)
|
if(stat(path, &st) == -1)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +121,7 @@ typedef std::size_t FileSize;
|
||||||
/// \brief Returns the size in bytes of the file identified by \p path, or 0 if the file was not found.
|
/// \brief Returns the size in bytes of the file identified by \p path, or 0 if the file was not found.
|
||||||
inline FileSize file_size(const char* path)
|
inline FileSize file_size(const char* path)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(path != 0, "file_size: invalid path");
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(stat(path, &st) == -1)
|
if(stat(path, &st) == -1)
|
||||||
{
|
{
|
||||||
|
@ -130,6 +138,7 @@ const FileTime c_invalidFileTime = -1;
|
||||||
/// \brief Returns the time that the file identified by \p path was last modified, or c_invalidFileTime if the file was not found.
|
/// \brief Returns the time that the file identified by \p path was last modified, or c_invalidFileTime if the file was not found.
|
||||||
inline FileTime file_modified(const char* path)
|
inline FileTime file_modified(const char* path)
|
||||||
{
|
{
|
||||||
|
ASSERT_MESSAGE(path != 0, "file_modified: invalid path");
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if(stat(path, &st) == -1)
|
if(stat(path, &st) == -1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue