시작하기 전에 다음 도구가 설치되어 있어야 한다.
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
vcpkg install POCO
기본적으로 x86 라이브러리가 설치된다. x64용을 설치하려면 다음 명령줄 처럼 사용한다.
vcpkg install [package name]:x64-windows
외부 IDE 에서 CMake와 함께 vcpkg를 사용하려면 툴체인 파일을 사용한다. 툴체인 파일 경로를 CMAKE_TOOLCHAIN_FILE
변수에 설정한다.
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(helloworld LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this is heuristically generated, and may not be correct
find_package(Poco CONFIG REQUIRED Net XML Zip Data Util)
add_executable(helloworld
main.cpp
)
target_link_libraries(helloworld PRIVATE Poco::Net Poco::XML Poco::Zip Poco::Data Poco::Util)
main.cpp
#include "Poco/DirectoryWatcher.h"
#include "Poco/Delegate.h"
#include "Poco/FileStream.h"
#include "Poco/Path.h"
#include <iostream>
#define DEBUG(msg) std::cout << msg << std::endl;
class Monitor {
public:
~Monitor(){}
void onItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& ev);
void onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& ev);
void onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev);
void onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& ev);
void onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& ev);
};
void Monitor::onItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& ev)
{
DEBUG("Added: " << ev.item.path())
}
void Monitor::onItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& ev)
{
DEBUG("Removed: " << ev.item.path())
}
void Monitor::onItemModified(const Poco::DirectoryWatcher::DirectoryEvent& ev)
{
DEBUG("Modified: " << ev.item.path())
}
void Monitor::onItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& ev)
{
DEBUG("MovedFrom: " << ev.item.path())
}
void Monitor::onItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& ev)
{
DEBUG("MovedTo: " << ev.item.path())
}
Poco::Path path()
{
Poco::Path p(Poco::Path::current());
p.pushDirectory(".");
return p;
}
int main(int argc, char *argv[])
{
try{
Poco::Path p(path());
p.setFileName("test.txt");
Poco::FileOutputStream fos(p.toString());
fos << "Hello, world!";
fos.close();
Poco::DirectoryWatcher dw(path().toString(), Poco::DirectoryWatcher::DW_FILTER_ENABLE_ALL, 2);
Monitor monitor;
dw.itemAdded += Poco::delegate(&monitor, &Monitor::onItemAdded);
dw.itemRemoved += Poco::delegate(&monitor, &Monitor::onItemRemoved);
dw.itemModified += Poco::delegate(&monitor, &Monitor::onItemModified);
dw.itemMovedFrom += Poco::delegate(&monitor, &Monitor::onItemMovedFrom);
dw.itemMovedTo += Poco::delegate(&monitor, &Monitor::onItemMovedTo);
Poco::Thread::sleep(1000);
Poco::FileOutputStream fos2(p.toString(), std::ios::app);
fos2 << "Again!";
fos2.close();
// loop
while(1)
Poco::Thread::sleep(2000 * dw.scanInterval());
}catch (const Poco::Exception &ex){
DEBUG(ex.what())
}
}
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
15 |
ZeroMQ 비동기 클라이언트/서버 패턴
![]() | makersweb | 2020.08.13 | 1843 |
14 |
AGL (Automotive Grade Linux) 개요
![]() | makersweb | 2022.06.19 | 1903 |
13 |
Nana, C++용 크로스플랫폼 GUI 라이브러리
![]() | makersweb | 2021.01.06 | 2100 |
12 |
Wayland IVI Extension 간단 리뷰
![]() | makersweb | 2019.05.12 | 2272 |
11 |
Flutter Application 에서 한글(EUC-KR) 깨져서 나오는 문제
![]() | makersweb | 2022.01.06 | 2758 |
10 |
리눅스에서 SDL2 최신버전 컴파일과 Qt Creator로 개발환경 구성
![]() | makersweb | 2019.10.06 | 3066 |
9 |
[SDL2 와 OpenGL]윈도우 생성과 2D그래픽
![]() | makersweb | 2020.04.11 | 3113 |
8 |
가볍고 쉬운 임베디드용 그래픽 라이브러리 - LVGL
![]() | makersweb | 2020.09.16 | 3511 |
7 |
webOS소개 및 Raspberry Pi 3 에서 실행
![]() | makersweb | 2019.10.13 | 3909 |
6 |
텔레그램(Telegram) Bot 개발
![]() | makersweb | 2019.07.21 | 5744 |
5 |
ZeroMQ의 기본 메세지 패턴들
![]() | makersweb | 2020.07.31 | 8632 |
4 |
GENIVI DLT(Diagnostic Log and Trace) 활용
![]() | makersweb | 2020.11.19 | 8695 |
3 |
Dear ImGui, 경량의 C++ 용 GUI 및 Widget 라이브러리
![]() | makersweb | 2020.11.28 | 9174 |
2 |
GDBus 튜토리얼(GDBus tutorial)
![]() | makersweb | 2019.06.30 | 10474 |
1 |
Pluma(C++ Plug-in Management Framework) 튜토리얼
![]() | makersweb | 2019.12.07 | 14061 |