// タイトルをセットする void CMenuPart::setTitle(const wxString& title) { m_title = title.Clone(); }
bool wxFsEventsFileSystemWatcher::AddTree(const wxFileName& path, int events, const wxString& filespec) { if (!path.DirExists()) { return false; } wxString canonical = GetCanonicalPath(path); if ( canonical.empty() ) { return false; } CFRunLoopRef cfLoop = CFRunLoopGetCurrent(); wxASSERT_MSG( cfLoop, "there must be a current event loop; this file watcher needs it." ); if ( ! cfLoop ) { return false; } if ( m_streams.find(canonical) != m_streams.end() ) { // How to take into account filespec // if client adds a watch for /home/*.cpp // and then on another call wants to add a // call to /home/*.h // Ideally we should not create another watch // however we would need to keep both filespecs // around, which we don't do now. return false; } // Will need to pass the desired event flags // and filespec to our callback via the context // we make sure to give the context a cleanup // callback. FSEventStreamContext ctx; wxFSEventWatcherContext* watcherContext = new wxFSEventWatcherContext( this, events, filespec.Clone() ); ctx.version = 0; ctx.info = watcherContext; ctx.retain = NULL; ctx.release = &wxDeleteContext; ctx.copyDescription = NULL; CFTimeInterval latency = 0.2; wxMacUniCharBuffer pathChars(path.GetPath()); CFStringRef pathRef = CFStringCreateWithCharacters( kCFAllocatorDefault, pathChars.GetBuffer(), pathChars.GetChars() ); CFArrayRef pathRefs = CFArrayCreate( kCFAllocatorDefault, (const void**)&pathRef, 1, NULL ); FSEventStreamCreateFlags flags = kFSEventStreamCreateFlagWatchRoot | kFSEventStreamCreateFlagFileEvents; FSEventStreamRef stream = FSEventStreamCreate( kCFAllocatorDefault, &wxFSEventCallback, &ctx, pathRefs, kFSEventStreamEventIdSinceNow, latency, flags); bool started = false; if ( stream ) { FSEventStreamScheduleWithRunLoop(stream, cfLoop, kCFRunLoopDefaultMode); started = FSEventStreamStart(stream); if ( started ) { m_streams[canonical] = stream; } } // cleanup the paths, as we own the pointers CFRelease(pathRef); CFRelease(pathRefs); wxASSERT_MSG(stream, "could not create FS stream"); return started; }