#if defined( WIN32 )
#define S_ISDIR(mode) (mode & _S_IFDIR)
-#include <io.h> // access()
+#include <io.h> // _access()
#define F_OK 0x00
#define W_OK 0x02
#define R_OK 0x04
+#define access(path, mode) _access(path, mode)
#else
#include <unistd.h> // access()
#endif
#include <cstddef>
#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.
///
/// The operation will fail unless:
/// - 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)
{
+ ASSERT_MESSAGE(from != 0 && to != 0, "file_move: invalid path");
return rename(from, to) == 0;
}
/// - The parent-directory component of \p path identifies an existing directory which is accessible for writing.
inline bool file_remove(const char* path)
{
+ ASSERT_MESSAGE(path != 0, "file_remove: invalid path");
return remove(path) == 0;
}
/// \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)
{
+ ASSERT_MESSAGE(path != 0, "file_accessible: invalid path");
return access(path, static_cast<int>(mode)) == 0;
}
/// \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)
{
+ ASSERT_MESSAGE(path != 0, "file_is_directory: invalid path");
struct stat st;
if(stat(path, &st) == -1)
{
/// \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)
{
+ ASSERT_MESSAGE(path != 0, "file_size: invalid path");
struct stat st;
if(stat(path, &st) == -1)
{
/// \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)
{
+ ASSERT_MESSAGE(path != 0, "file_modified: invalid path");
struct stat st;
if(stat(path, &st) == -1)
{