Skip to content

Commit

Permalink
Fixed some cross platform issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
saintonfire committed Sep 15, 2009
1 parent ea4102f commit 62bf410
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
16 changes: 4 additions & 12 deletions SimpleDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <FileWatcher/FileWatcher.h>
#include <iostream>
#include <conio.h>

/// Processes a file action
class UpdateListener : public FW::FileWatchListener
Expand All @@ -50,24 +49,17 @@ int main(int argc, char **argv)
// create the file watcher object
FW::FileWatcher fileWatcher;

// create an instance of UpdateListener on the stack
UpdateListener updateListener;

// add a watch to the system
FW::WatchID watchID = fileWatcher.addWatch("./test", &updateListener);
FW::WatchID watchID = fileWatcher.addWatch("./test", new UpdateListener());

std::cout << "Press <enter> to exit demo" << std::endl;
std::cout << "Press ^C to exit demo" << std::endl;

// loop until a key is pressed
while(!_kbhit())
while(1)
{
fileWatcher.update();
}
std::cin.ignore();

// now remove the watch, otherwise FileWatcher will mistake updateListener
// for something that should be cleaned up.
fileWatcher.removeWatch(watchID);
kj
}
catch( std::exception& e )
{
Expand Down
1 change: 1 addition & 0 deletions includes/FileWatcher/FileWatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#pragma once

#include <string>
#include <stdexcept>

namespace FW
{
Expand Down
2 changes: 1 addition & 1 deletion includes/FileWatcher/FileWatcherLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace FW
{
/// Implementation for Linux based on inotify.
/// @class FileWatcherLinux
class FileWatcherLinux
class FileWatcherLinux : public FileWatcherImpl
{
public:
/// type for a map from WatchID to WatchStruct pointer
Expand Down
2 changes: 1 addition & 1 deletion includes/FileWatcher/FileWatcherOSX.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace FW
{
/// Implementation for OSX based on kqueue.
/// @class FileWatcherOSX
class FileWatcherOSX
class FileWatcherOSX : public FileWatcherImpl
{
public:
/// type for a map from WatchID to WatchStruct pointer
Expand Down
1 change: 1 addition & 0 deletions source/FileWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include <FileWatcher/FileWatcher.h>
#include <FileWatcher/FileWatcherImpl.h>

#if FILEWATCHER_PLATFORM == FILEWATCHER_PLATFORM_WIN32
# include <FileWatcher/FileWatcherWin32.h>
Expand Down

0 comments on commit 62bf410

Please sign in to comment.