dir_path_ = full_path.parent_path();
target_name_ = full_path.filename().string();
dir_ = g_file_new_for_path(dir_path_.c_str());
+ if (!dir_)
+ throw std::runtime_error("Failed to create directory");
+
monitor_ =
g_file_monitor_directory(dir_, G_FILE_MONITOR_NONE, nullptr, nullptr);
if (monitor_ == nullptr) {
g_object_unref(dir_);
- dir_ = nullptr;
- std::runtime_error("Failed to create monitor");
+ throw std::runtime_error("Failed to create monitor");
}
g_signal_connect(monitor_, "changed", G_CALLBACK(OnFileChanged), this);
if (mode_ == PathInfo::Mode::Created && fs::exists(full_path, error)) {
- if (monitor_) {
- g_object_unref(monitor_);
- monitor_ = nullptr;
- }
-
- if (dir_) {
- g_object_unref(dir_);
- dir_ = nullptr;
- }
+ g_object_unref(monitor_);
+ monitor_ = nullptr;
+
+ g_object_unref(dir_);
+ dir_ = nullptr;
NotifyEvent();
}