Rename DroppedFile to NativeFile.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2019-12-20 00:32:56 -04:00
parent c2ccb56117
commit 2a7e39d58b
8 changed files with 65 additions and 74 deletions
+3 -3
View File
@@ -20,7 +20,7 @@
#include "Event.h"
#include "filesystem/DroppedFile.h"
#include "filesystem/NativeFile.h"
#include "filesystem/Filesystem.h"
#include "keyboard/sdl/Keyboard.h"
#include "joystick/JoystickModule.h"
@@ -418,8 +418,8 @@ Message *Event::convert(const SDL_Event &e)
}
else
{
auto *file = new love::filesystem::DroppedFile(e.drop.file);
vargs.emplace_back(&love::filesystem::DroppedFile::type, file);
auto *file = new love::filesystem::NativeFile(e.drop.file);
vargs.emplace_back(&love::filesystem::NativeFile::type, file);
msg = new Message("filedropped", vargs);
file->release();
}
@@ -19,7 +19,7 @@
**/
// LOVE
#include "DroppedFile.h"
#include "NativeFile.h"
#include "common/utf8.h"
// Assume POSIX or Visual Studio.
@@ -37,9 +37,9 @@ namespace love
namespace filesystem
{
love::Type DroppedFile::type("DroppedFile", &File::type);
love::Type NativeFile::type("NativeFile", &File::type);
DroppedFile::DroppedFile(const std::string &filename)
NativeFile::NativeFile(const std::string &filename)
: filename(filename)
, file(nullptr)
, mode(MODE_CLOSED)
@@ -48,13 +48,13 @@ DroppedFile::DroppedFile(const std::string &filename)
{
}
DroppedFile::~DroppedFile()
NativeFile::~NativeFile()
{
if (mode != MODE_CLOSED)
close();
}
bool DroppedFile::open(Mode newmode)
bool NativeFile::open(Mode newmode)
{
if (newmode == MODE_CLOSED)
return true;
@@ -88,7 +88,7 @@ bool DroppedFile::open(Mode newmode)
return file != nullptr;
}
bool DroppedFile::close()
bool NativeFile::close()
{
if (file == nullptr || fclose(file) != 0)
return false;
@@ -99,12 +99,12 @@ bool DroppedFile::close()
return true;
}
bool DroppedFile::isOpen() const
bool NativeFile::isOpen() const
{
return mode != MODE_CLOSED && file != nullptr;
}
int64 DroppedFile::getSize()
int64 NativeFile::getSize()
{
#ifdef LOVE_WINDOWS
@@ -129,7 +129,7 @@ int64 DroppedFile::getSize()
#endif
}
int64 DroppedFile::read(void *dst, int64 size)
int64 NativeFile::read(void *dst, int64 size)
{
if (!file || mode != MODE_READ)
throw love::Exception("File is not opened for reading.");
@@ -142,7 +142,7 @@ int64 DroppedFile::read(void *dst, int64 size)
return (int64) read;
}
bool DroppedFile::write(const void *data, int64 size)
bool NativeFile::write(const void *data, int64 size)
{
if (!file || (mode != MODE_WRITE && mode != MODE_APPEND))
throw love::Exception("File is not opened for writing.");
@@ -155,7 +155,7 @@ bool DroppedFile::write(const void *data, int64 size)
return written == size;
}
bool DroppedFile::flush()
bool NativeFile::flush()
{
if (!file || (mode != MODE_WRITE && mode != MODE_APPEND))
throw love::Exception("File is not opened for writing.");
@@ -163,12 +163,12 @@ bool DroppedFile::flush()
return fflush(file) == 0;
}
bool DroppedFile::isEOF()
bool NativeFile::isEOF()
{
return file == nullptr || feof(file) != 0;
}
int64 DroppedFile::tell()
int64 NativeFile::tell()
{
if (file == nullptr)
return -1;
@@ -176,12 +176,12 @@ int64 DroppedFile::tell()
return (int64) ftell(file);
}
bool DroppedFile::seek(uint64 pos)
bool NativeFile::seek(uint64 pos)
{
return file != nullptr && fseek(file, (long) pos, SEEK_SET) == 0;
}
bool DroppedFile::setBuffer(BufferMode bufmode, int64 size)
bool NativeFile::setBuffer(BufferMode bufmode, int64 size)
{
if (size < 0)
return false;
@@ -190,7 +190,7 @@ bool DroppedFile::setBuffer(BufferMode bufmode, int64 size)
size = 0;
// If the file isn't open, we'll make sure the buffer values are set in
// DroppedFile::open.
// NativeFile::open.
if (!isOpen())
{
bufferMode = bufmode;
@@ -222,23 +222,23 @@ bool DroppedFile::setBuffer(BufferMode bufmode, int64 size)
return true;
}
File::BufferMode DroppedFile::getBuffer(int64 &size) const
File::BufferMode NativeFile::getBuffer(int64 &size) const
{
size = bufferSize;
return bufferMode;
}
const std::string &DroppedFile::getFilename() const
const std::string &NativeFile::getFilename() const
{
return filename;
}
File::Mode DroppedFile::getMode() const
File::Mode NativeFile::getMode() const
{
return mode;
}
const char *DroppedFile::getModeString(Mode mode)
const char *NativeFile::getModeString(Mode mode)
{
switch (mode)
{
@@ -18,9 +18,6 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_FILESYSTEM_DROPPED_FILE_H
#define LOVE_FILESYSTEM_DROPPED_FILE_H
// LOVE
#include "common/config.h"
#include "File.h"
@@ -34,17 +31,16 @@ namespace filesystem
{
/**
* File which is created when a user drags and drops an actual file onto the
* LOVE game. Uses C's stdio. Filenames are system-dependent full paths.
* File which uses C's stdio. Filenames are system-dependent full paths.
**/
class DroppedFile : public File
class NativeFile : public File
{
public:
static love::Type type;
DroppedFile(const std::string &filename);
virtual ~DroppedFile();
NativeFile(const std::string &filename);
virtual ~NativeFile();
// Implements File.
using File::read;
@@ -77,9 +73,7 @@ private:
BufferMode bufferMode;
int64 bufferSize;
}; // DroppedFile
}; // NativeFile
} // filesystem
} // love
#endif // LOVE_FILESYSTEM_DROPPED_FILE_H
+4 -4
View File
@@ -22,7 +22,7 @@
#include "common/config.h"
#include "wrap_Filesystem.h"
#include "wrap_File.h"
#include "wrap_DroppedFile.h"
#include "wrap_NativeFile.h"
#include "wrap_FileData.h"
#include "data/wrap_Data.h"
#include "data/wrap_DataModule.h"
@@ -133,9 +133,9 @@ int w_mount(lua_State *L)
luax_pushboolean(L, instance()->mount(data, archive.c_str(), mountpoint, append));
return 1;
}
else if (luax_istype(L, 1, DroppedFile::type))
else if (luax_istype(L, 1, NativeFile::type))
{
DroppedFile *file = luax_totype<DroppedFile>(L, 1);
NativeFile *file = luax_totype<NativeFile>(L, 1);
archive = file->getFilename();
}
else
@@ -958,7 +958,7 @@ static const luaL_Reg functions[] =
static const lua_CFunction types[] =
{
luaopen_file,
luaopen_droppedfile,
luaopen_nativefile,
luaopen_filedata,
0
};
@@ -18,7 +18,7 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#include "wrap_DroppedFile.h"
#include "wrap_NativeFile.h"
#include "wrap_File.h"
namespace love
@@ -26,14 +26,14 @@ namespace love
namespace filesystem
{
DroppedFile *luax_checkdroppedfile(lua_State *L, int idx)
NativeFile *luax_checknativefile(lua_State *L, int idx)
{
return luax_checktype<DroppedFile>(L, idx);
return luax_checktype<NativeFile>(L, idx);
}
extern "C" int luaopen_droppedfile(lua_State *L)
extern "C" int luaopen_nativefile(lua_State *L)
{
return luax_register_type(L, &DroppedFile::type, w_File_functions, nullptr);
return luax_register_type(L, &NativeFile::type, w_File_functions, nullptr);
}
} // filesystem
@@ -18,22 +18,19 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_FILESYSTEM_WRAP_DROPPED_FILE_H
#define LOVE_FILESYSTEM_WRAP_DROPPED_FILE_H
#pragma once
// LOVE
#include "common/runtime.h"
#include "DroppedFile.h"
#include "NativeFile.h"
namespace love
{
namespace filesystem
{
DroppedFile *luax_checkdroppedfile(lua_State *L, int idx);
extern "C" int luaopen_droppedfile(lua_State *L);
NativeFile *luax_checknativefile(lua_State *L, int idx);
extern "C" int luaopen_nativefile(lua_State *L);
} // filesystem
} // love
#endif // LOVE_FILESYSTEM_WRAP_DROPPED_FILE_H