Rename new API to FileWatcher (resolve #1064)
This commit is contained in:
@@ -219,7 +219,7 @@
|
||||
<compilerflag value="-I${NATIVE_TOOLKIT_PATH}/simplefilewatcher/include/" />
|
||||
<compilerflag value="-DLIME_SIMPLEFILEWATCHER" />
|
||||
|
||||
<file name="src/system/DirectoryWatcher.cpp" />
|
||||
<file name="src/system/FileWatcher.cpp" />
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#ifndef LIME_SYSTEM_DIRECTORY_WATCHER_H
|
||||
#define LIME_SYSTEM_DIRECTORY_WATCHER_H
|
||||
|
||||
#include <hx/CFFI.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class DirectoryWatcher {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DirectoryWatcher (value callback);
|
||||
~DirectoryWatcher ();
|
||||
|
||||
unsigned long AddWatch (const std::string directory, bool recursive);
|
||||
void RemoveWatch (unsigned long watchID);
|
||||
void Update ();
|
||||
|
||||
AutoGCRoot* callback;
|
||||
|
||||
private:
|
||||
|
||||
void* fileWatcher = 0;
|
||||
std::map<unsigned long, void*> watchListeners;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
42
project/include/system/FileWatcher.h
Normal file
42
project/include/system/FileWatcher.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef LIME_SYSTEM_FILE_WATCHER_H
|
||||
#define LIME_SYSTEM_FILE_WATCHER_H
|
||||
|
||||
#ifdef RemoveDirectory
|
||||
#undef RemoveDirectory
|
||||
#endif
|
||||
|
||||
#include <hx/CFFI.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class FileWatcher {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
FileWatcher (value callback);
|
||||
~FileWatcher ();
|
||||
|
||||
unsigned long AddDirectory (const std::string directory, bool recursive);
|
||||
void RemoveDirectory (unsigned long watchID);
|
||||
void Update ();
|
||||
|
||||
AutoGCRoot* callback;
|
||||
|
||||
private:
|
||||
|
||||
void* fileWatcher = 0;
|
||||
std::map<unsigned long, void*> watchListeners;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <system/CFFIPointer.h>
|
||||
#include <system/Clipboard.h>
|
||||
#include <system/ClipboardEvent.h>
|
||||
#include <system/DirectoryWatcher.h>
|
||||
#include <system/Endian.h>
|
||||
#include <system/FileWatcher.h>
|
||||
#include <system/JNI.h>
|
||||
#include <system/Locale.h>
|
||||
#include <system/SensorEvent.h>
|
||||
@@ -65,10 +65,10 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void gc_directory_watcher (value handle) {
|
||||
void gc_file_watcher (value handle) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
DirectoryWatcher* watcher = (DirectoryWatcher*)val_data (handle);
|
||||
FileWatcher* watcher = (FileWatcher*)val_data (handle);
|
||||
delete watcher;
|
||||
#endif
|
||||
|
||||
@@ -360,50 +360,6 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_directory_watcher_create (value callback) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
DirectoryWatcher* watcher = new DirectoryWatcher (callback);
|
||||
return CFFIPointer (watcher, gc_directory_watcher);
|
||||
#else
|
||||
return alloc_null ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_directory_watcher_add_watch (value handle, value path, bool recursive) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
DirectoryWatcher* watcher = (DirectoryWatcher*)val_data (handle);
|
||||
return alloc_int (watcher->AddWatch (val_string (path), recursive));
|
||||
#else
|
||||
return alloc_int (0);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_directory_watcher_remove_watch (value handle, value watchID) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
DirectoryWatcher* watcher = (DirectoryWatcher*)val_data (handle);
|
||||
watcher->RemoveWatch (val_int (watchID));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_directory_watcher_update (value handle) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
DirectoryWatcher* watcher = (DirectoryWatcher*)val_data (handle);
|
||||
watcher->Update ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_drop_event_manager_register (value callback, value eventObject) {
|
||||
|
||||
DropEvent::callback = new AutoGCRoot (callback);
|
||||
@@ -546,6 +502,51 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value lime_file_watcher_create (value callback) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
FileWatcher* watcher = new FileWatcher (callback);
|
||||
return CFFIPointer (watcher, gc_file_watcher);
|
||||
#else
|
||||
return alloc_null ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_file_watcher_add_directory (value handle, value path, bool recursive) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
FileWatcher* watcher = (FileWatcher*)val_data (handle);
|
||||
return alloc_int (watcher->AddDirectory (val_string (path), recursive));
|
||||
#else
|
||||
return alloc_int (0);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_file_watcher_remove_directory (value handle, value watchID) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
FileWatcher* watcher = (FileWatcher*)val_data (handle);
|
||||
watcher->RemoveDirectory (val_int (watchID));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_file_watcher_update (value handle) {
|
||||
|
||||
#ifdef LIME_SIMPLEFILEWATCHER
|
||||
FileWatcher* watcher = (FileWatcher*)val_data (handle);
|
||||
watcher->Update ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
int lime_font_get_ascender (value fontHandle) {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
@@ -1888,15 +1889,15 @@ namespace lime {
|
||||
DEFINE_PRIME2 (lime_data_pointer_offset);
|
||||
DEFINE_PRIME2 (lime_deflate_compress);
|
||||
DEFINE_PRIME2 (lime_deflate_decompress);
|
||||
DEFINE_PRIME1 (lime_directory_watcher_create);
|
||||
DEFINE_PRIME3 (lime_directory_watcher_add_watch);
|
||||
DEFINE_PRIME2v (lime_directory_watcher_remove_watch);
|
||||
DEFINE_PRIME1v (lime_directory_watcher_update);
|
||||
DEFINE_PRIME2v (lime_drop_event_manager_register);
|
||||
DEFINE_PRIME3 (lime_file_dialog_open_directory);
|
||||
DEFINE_PRIME3 (lime_file_dialog_open_file);
|
||||
DEFINE_PRIME3 (lime_file_dialog_open_files);
|
||||
DEFINE_PRIME3 (lime_file_dialog_save_file);
|
||||
DEFINE_PRIME1 (lime_file_watcher_create);
|
||||
DEFINE_PRIME3 (lime_file_watcher_add_directory);
|
||||
DEFINE_PRIME2v (lime_file_watcher_remove_directory);
|
||||
DEFINE_PRIME1v (lime_file_watcher_update);
|
||||
DEFINE_PRIME1 (lime_font_get_ascender);
|
||||
DEFINE_PRIME1 (lime_font_get_descender);
|
||||
DEFINE_PRIME1 (lime_font_get_family_name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <system/DirectoryWatcher.h>
|
||||
#include <system/FileWatcher.h>
|
||||
#include <FileWatcher/FileWatcher.h>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace lime {
|
||||
|
||||
public:
|
||||
|
||||
UpdateListener (DirectoryWatcher* _watcher) {
|
||||
UpdateListener (FileWatcher* _watcher) {
|
||||
|
||||
watcher = _watcher;
|
||||
|
||||
@@ -22,13 +22,12 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
DirectoryWatcher* watcher;
|
||||
|
||||
FileWatcher* watcher;
|
||||
|
||||
};
|
||||
|
||||
|
||||
DirectoryWatcher::DirectoryWatcher (value _callback) {
|
||||
FileWatcher::FileWatcher (value _callback) {
|
||||
|
||||
callback = new AutoGCRoot (_callback);
|
||||
fileWatcher = new FW::FileWatcher ();
|
||||
@@ -36,7 +35,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
DirectoryWatcher::~DirectoryWatcher () {
|
||||
FileWatcher::~FileWatcher () {
|
||||
|
||||
delete callback;
|
||||
delete fileWatcher;
|
||||
@@ -52,7 +51,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
unsigned long DirectoryWatcher::AddWatch (std::string directory, bool recursive) {
|
||||
unsigned long FileWatcher::AddDirectory (std::string directory, bool recursive) {
|
||||
|
||||
UpdateListener* listener = new UpdateListener (this);
|
||||
FW::WatchID watchID = ((FW::FileWatcher*)fileWatcher)->addWatch (directory, listener, true);
|
||||
@@ -62,7 +61,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void DirectoryWatcher::RemoveWatch (unsigned long watchID) {
|
||||
void FileWatcher::RemoveDirectory (unsigned long watchID) {
|
||||
|
||||
((FW::FileWatcher*)fileWatcher)->removeWatch (watchID);
|
||||
|
||||
@@ -76,7 +75,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void DirectoryWatcher::Update () {
|
||||
void FileWatcher::Update () {
|
||||
|
||||
((FW::FileWatcher*)fileWatcher)->update ();
|
||||
|
||||
Reference in New Issue
Block a user