本文整理汇总了C++中BEntry::GetNodeRef方法的典型用法代码示例。如果您正苦于以下问题:C++ BEntry::GetNodeRef方法的具体用法?C++ BEntry::GetNodeRef怎么用?C++ BEntry::GetNodeRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BEntry
的用法示例。
在下文中一共展示了BEntry::GetNodeRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
PathHandler::_EntryCreated(BMessage* message)
{
const char* name;
node_ref nodeRef;
if (message->FindInt32("device", &nodeRef.device) != B_OK
|| message->FindInt64("directory", &nodeRef.node) != B_OK
|| message->FindString("name", &name) != B_OK) {
TRACE("PathHandler::_EntryCreated() - malformed message!\n");
return;
}
BEntry entry;
if (set_entry(nodeRef, name, entry) != B_OK) {
TRACE("PathHandler::_EntryCreated() - set_entry failed!\n");
return;
}
bool parentContained = false;
bool entryContained = _IsContained(entry);
if (entryContained)
parentContained = _IsContained(nodeRef);
bool notify = entryContained;
if (entry.IsDirectory()) {
// ignore the directory if it's already known
if (entry.GetNodeRef(&nodeRef) == B_OK
&& _HasDirectory(nodeRef)) {
TRACE(" WE ALREADY HAVE DIR %s, %ld:%Ld\n",
name, nodeRef.device, nodeRef.node);
return;
}
// a new directory to watch for us
if ((!entryContained && !_CloserToPath(entry))
|| (parentContained && !_WatchRecursively())
|| _AddDirectory(entry, true) != B_OK
|| _WatchFilesOnly())
notify = parentContained;
// NOTE: entry is now toast after _AddDirectory() was called!
// Does not matter right now, but if it's a problem, use the node_ref
// version...
} else if (entryContained) {
TRACE(" NEW ENTRY PARENT CONTAINED: %d\n", parentContained);
_AddFile(entry);
}
if (notify && entryContained) {
message->AddBool("added", true);
// nodeRef is pointing to the parent directory
entry.GetNodeRef(&nodeRef);
_NotifyTarget(message, nodeRef);
}
}
示例2: entry
/*! Starts watching the settings file, or if that doesn't exist, the directory
the settings file will be placed into.
*/
void
ScreenSaverFilter::_WatchSettings()
{
BEntry entry(fSettings.Path().Path());
if (entry.Exists()) {
if (fWatchingFile)
return;
if (fWatchingDirectory) {
watch_node(&fNodeRef, B_STOP_WATCHING, fController);
fWatchingDirectory = false;
}
if (entry.GetNodeRef(&fNodeRef) == B_OK
&& watch_node(&fNodeRef, B_WATCH_ALL, fController) == B_OK)
fWatchingFile = true;
} else {
if (fWatchingDirectory)
return;
if (fWatchingFile) {
watch_node(&fNodeRef, B_STOP_WATCHING, fController);
fWatchingFile = false;
}
BEntry dir;
if (entry.GetParent(&dir) == B_OK
&& dir.GetNodeRef(&fNodeRef) == B_OK
&& watch_node(&fNodeRef, B_WATCH_DIRECTORY, fController) == B_OK)
fWatchingDirectory = true;
}
}
示例3: dir
status_t
UninstallView::_ReloadAppList()
{
_ClearAppList();
if (fToPackages.InitCheck() != B_OK)
_CachePathToPackages();
BDirectory dir(fToPackages.Path());
status_t ret = dir.InitCheck();
if (ret != B_OK)
return ret;
fprintf(stderr, "Ichi! %s\n", fToPackages.Path());
BEntry iter;
while (dir.GetNextEntry(&iter) == B_OK) {
char filename[B_FILE_NAME_LENGTH];
if (iter.GetName(filename) != B_OK)
continue;
node_ref ref;
if (iter.GetNodeRef(&ref) != B_OK)
continue;
printf("Found package '%s'\n", filename);
_AddFile(filename, ref);
}
if (ret != B_ENTRY_NOT_FOUND)
return ret;
return B_OK;
}
示例4: Directory
status_t
DirectoryView::OpenDirectory(const Entry* dir)
{
if (! dir->IsDirectory()) {
return B_ERROR;
}
// stop node watcher
stop_watching(this);
// clear entry data and listview
mListView->DeleteAllItems();
entryList_.DeleteAllItems();
if (entry_) {
delete entry_;
entry_ = NULL;
}
if (parent_) {
delete parent_;
parent_ = NULL;
}
UpdateStatus();
// set current directory
entry_ = new Directory(*(Directory*)dir);
// get parent directory
BEntry bentry;
if (entry_->GetBEntry(&bentry) == B_OK) {
BEntry parent;
if (bentry.GetParent(&parent) == B_OK) {
parent_ = new Directory(parent);
}
}
// get directory entry
ListVisitor* lv1 = new ListVisitor(*entry_, &entryList_);
lv1->Go();
delete lv1;
// show directory entry
if (parent_ != NULL) {
mListView->AddItem(new EntryListItem(parent_, EntryListItem::ENTRY_IS_PARENT));
}
mListView->AddEntryList((BList*) &entryList_);
mListView->DoSort();
if (mListView->CountItems() > 0)
mListView->Select(0);
UpdateStatus();
// start node watcher
if (bentry.InitCheck() == B_OK) {
node_ref nref;
bentry.GetNodeRef(&nref);
watch_node(&nref, B_WATCH_ALL, this);
}
return B_OK;
}
示例5: _RemoveFile
status_t
PathHandler::_RemoveFile(BEntry& entry)
{
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status != B_OK)
return status;
return _RemoveFile(nodeRef);
}
示例6: _RemoveDirectory
status_t
PathHandler::_RemoveDirectory(BEntry& entry, ino_t directoryNode)
{
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status != B_OK)
return status;
return _RemoveDirectory(nodeRef, directoryNode);
}
示例7: path
status_t
FontManager::_AddPath(BEntry& entry, font_directory** _newDirectory)
{
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status != B_OK)
return status;
// check if we are already know this directory
font_directory* directory = _FindDirectory(nodeRef);
if (directory != NULL) {
if (_newDirectory)
*_newDirectory = directory;
return B_OK;
}
// it's a new one, so let's add it
directory = new (std::nothrow) font_directory;
if (directory == NULL)
return B_NO_MEMORY;
struct stat stat;
status = entry.GetStat(&stat);
if (status != B_OK) {
delete directory;
return status;
}
directory->directory = nodeRef;
directory->user = stat.st_uid;
directory->group = stat.st_gid;
directory->revision = 0;
status = watch_node(&nodeRef, B_WATCH_DIRECTORY, this);
if (status != B_OK) {
// we cannot watch this directory - while this is unfortunate,
// it's not a critical error
printf("could not watch directory %ld:%Ld\n", nodeRef.device,
nodeRef.node);
// TODO: should go into syslog()
} else {
BPath path(&entry);
FTRACE(("FontManager: now watching: %s\n", path.Path()));
}
fDirectories.AddItem(directory);
if (_newDirectory)
*_newDirectory = directory;
fScanned = false;
return B_OK;
}
示例8: path
status_t
PathHandler::_AddFile(BEntry& entry, bool notify)
{
if ((fFlags & (WATCH_NODE_FLAG_MASK & ~B_WATCH_DIRECTORY)) == 0)
return B_OK;
#ifdef TRACE_PATH_MONITOR
{
BPath path(&entry);
TRACE(" ADD FILE %s\n", path.Path());
}
#endif
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status != B_OK)
return status;
// check if we already know this file
// TODO: It should be possible to omit this check if we know it
// can't be the case (for example when adding subfolders recursively,
// although in that case, the API user may still have added this file
// independently, so for now, it should be the safest to perform this
// check in all cases.)
if (_HasFile(nodeRef))
return B_OK;
status = watch_node(&nodeRef, (fFlags & WATCH_NODE_FLAG_MASK), this);
if (status != B_OK)
return status;
FileEntry setEntry;
entry.GetRef(&setEntry.ref);
setEntry.node = nodeRef.node;
fFiles.insert(setEntry);
if (notify && _WatchFilesOnly()) {
// We also notify our target about new files if it's only interested
// in files; it won't be notified about new directories, so it cannot
// know when to search for them.
BMessage update;
update.AddInt32("opcode", B_ENTRY_CREATED);
update.AddInt32("device", nodeRef.device);
update.AddInt64("directory", setEntry.ref.directory);
update.AddString("name", setEntry.ref.name);
update.AddBool("added", true);
_NotifyTarget(&update, nodeRef);
}
return B_OK;
}
示例9: new
/*! \brief Adds the FontFamily/FontStyle that is represented by this path.
*/
status_t
FontManager::_AddFont(font_directory& directory, BEntry& entry)
{
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status < B_OK)
return status;
BPath path;
status = entry.GetPath(&path);
if (status < B_OK)
return status;
FT_Face face;
FT_Error error = FT_New_Face(gFreeTypeLibrary, path.Path(), 0, &face);
if (error != 0)
return B_ERROR;
FontFamily *family = _FindFamily(face->family_name);
if (family != NULL && family->HasStyle(face->style_name)) {
// prevent adding the same style twice
// (this indicates a problem with the installed fonts maybe?)
FT_Done_Face(face);
return B_OK;
}
if (family == NULL) {
family = new (std::nothrow) FontFamily(face->family_name, fNextID++);
if (family == NULL
|| !fFamilies.BinaryInsert(family, compare_font_families)) {
delete family;
FT_Done_Face(face);
return B_NO_MEMORY;
}
}
FTRACE(("\tadd style: %s, %s\n", face->family_name, face->style_name));
// the FontStyle takes over ownership of the FT_Face object
FontStyle *style = new FontStyle(nodeRef, path.Path(), face);
if (!family->AddStyle(style)) {
delete style;
delete family;
return B_NO_MEMORY;
}
directory.styles.AddItem(style);
fStyleHashTable.AddItem(style);
if (directory.AlreadyScanned())
directory.revision++;
return B_OK;
}
示例10: sizeof
/*! \brief Sets the name of the volume referred to by this object.
\param name The volume's new name. Must not be longer than
\c B_FILE_NAME_LENGTH (including the terminating null).
\return
- \c B_OK: Everything went fine.
- \c B_BAD_VALUE: \c NULL \a name or the object is not properly
initialized.
- another error code
*/
status_t
BVolume::SetName(const char *name)
{
// check initialization
if (!name || InitCheck() != B_OK)
return B_BAD_VALUE;
if (strlen(name) >= B_FILE_NAME_LENGTH)
return B_NAME_TOO_LONG;
// get the FS stat (including the old name) first
fs_info oldInfo;
if (fs_stat_dev(fDevice, &oldInfo) != 0)
return errno;
if (strcmp(name, oldInfo.volume_name) == 0)
return B_OK;
// set the volume name
fs_info newInfo;
strlcpy(newInfo.volume_name, name, sizeof(newInfo.volume_name));
status_t error = _kern_write_fs_info(fDevice, &newInfo,
FS_WRITE_FSINFO_NAME);
if (error != B_OK)
return error;
// change the name of the mount point
// R5 implementation checks, if an entry with the volume's old name
// exists in the root directory and renames that entry, if it is indeed
// the mount point of the volume (or a link referring to it). In all other
// cases, nothing is done (even if the mount point is named like the
// volume, but lives in a different directory).
// We follow suit for the time being.
// NOTE: If the volume name itself is actually "boot", then this code
// tries to rename /boot, but that is prevented in the kernel.
BPath entryPath;
BEntry entry;
BEntry traversedEntry;
node_ref entryNodeRef;
if (BPrivate::Storage::check_entry_name(name) == B_OK
&& BPrivate::Storage::check_entry_name(oldInfo.volume_name) == B_OK
&& entryPath.SetTo("/", oldInfo.volume_name) == B_OK
&& entry.SetTo(entryPath.Path(), false) == B_OK
&& entry.Exists()
&& traversedEntry.SetTo(entryPath.Path(), true) == B_OK
&& traversedEntry.GetNodeRef(&entryNodeRef) == B_OK
&& entryNodeRef.device == fDevice
&& entryNodeRef.node == oldInfo.root) {
entry.Rename(name, false);
}
return error;
}
示例11: StartWatching
status_t HModuleRoster::StartWatching( BPath *moduleDirectory )
{
if( watching )
return B_ERROR;
printf("Watching %s\n", moduleDirectory->Path());
BEntry entry;
if( (entry.SetTo( moduleDirectory->Path() ) == B_OK)&&
(entry.GetNodeRef( &watchedRef ) == B_OK) )
{
watching = true;
return watch_node( &watchedRef, B_WATCH_DIRECTORY, this );
}
else
return B_ERROR;
}
示例12: DisableMonitoring
void PanelView::DisableMonitoring(void)
////////////////////////////////////////////////////////////////////////
{
BEntry entry;
node_ref nref;
entry.SetTo(m_Path.String());
if (entry.InitCheck()==B_OK)
{
if (entry.Exists())
{
entry.GetNodeRef(&nref);
if (watch_node(&nref, B_STOP_WATCHING , this)==B_OK)
m_MonitoringPath.SetTo("");
}
}
}
示例13: EnableMonitoring
void PanelView::EnableMonitoring()
////////////////////////////////////////////////////////////////////////
{
BEntry entry;
node_ref nref;
entry.SetTo(m_Path.String());
if (entry.InitCheck()==B_OK)
{
if (entry.Exists())
{
entry.GetNodeRef(&nref);
if (watch_node(&nref, B_WATCH_ALL | B_WATCH_MOUNT , this)==B_OK)
m_MonitoringPath = m_Path;
else
m_MonitoringPath.SetTo(""); // Empty string
}
}
}
示例14: font_directory
/*! \brief Creates all unknown font_directories of the specified path - but
only if one of its parent directories is already known.
This method is used to create the font_directories for font_mappings.
It recursively walks upwards in the directory hierarchy until it finds
a known font_directory (or hits the root directory, in which case it
bails out).
*/
status_t
FontManager::_CreateDirectories(const char* path)
{
FTRACE(("_CreateDirectories(path = %s)\n", path));
if (!strcmp(path, "/")) {
// we walked our way up to the root
return B_ENTRY_NOT_FOUND;
}
BEntry entry;
status_t status = entry.SetTo(path);
if (status != B_OK)
return status;
node_ref nodeRef;
status = entry.GetNodeRef(&nodeRef);
if (status != B_OK)
return status;
// check if we are already know this directory
font_directory* directory = _FindDirectory(nodeRef);
if (directory != NULL)
return B_OK;
// We don't know this one yet - keep walking the path upwards
// and try to find a match.
BPath parent(path);
status = parent.GetParent(&parent);
if (status != B_OK)
return status;
status = _CreateDirectories(parent.Path());
if (status != B_OK)
return status;
// We have our match, create sub directory
return _AddPath(path);
}
示例15:
//.........这里部分代码省略.........
// has the entry been moved into a monitored directory or has
// it been removed from one?
const char* name;
node_ref nodeRef;
uint64 fromNode;
uint64 node;
if (message->FindInt32("device", &nodeRef.device) != B_OK
|| message->FindInt64("to directory", &nodeRef.node) != B_OK
|| message->FindInt64("from directory", (int64 *)&fromNode) != B_OK
|| message->FindInt64("node", (int64 *)&node) != B_OK
|| message->FindString("name", &name) != B_OK)
break;
font_directory* directory = _FindDirectory(nodeRef);
BEntry entry;
if (set_entry(nodeRef, name, entry) != B_OK)
break;
if (directory != NULL) {
// something has been added to our watched font directories
// test, if the source directory is one of ours as well
nodeRef.node = fromNode;
font_directory* fromDirectory = _FindDirectory(nodeRef);
if (entry.IsDirectory()) {
if (fromDirectory == NULL) {
// there is a new directory to watch for us
_AddPath(entry);
FTRACE("new directory moved in");
} else {
// A directory from our watched directories has
// been renamed or moved within the watched
// directories - we only need to update the
// path names of the styles in that directory
nodeRef.node = node;
directory = _FindDirectory(nodeRef);
if (directory != NULL) {
for (int32 i = 0; i < directory->styles.CountItems(); i++) {
FontStyle* style = directory->styles.ItemAt(i);
style->UpdatePath(directory->directory);
}
}
FTRACE("directory renamed");
}
} else {
if (fromDirectory != NULL) {
// find style in source and move it to the target
nodeRef.node = node;
FontStyle* style = fromDirectory->FindStyle(nodeRef);
if (style != NULL) {
fromDirectory->styles.RemoveItem(style, false);
directory->styles.AddItem(style);
style->UpdatePath(directory->directory);
}
FTRACE(("font moved"));
} else {
FTRACE(("font added: %s\n", name));
_AddFont(*directory, entry);
}
}
} else {
// and entry has been removed from our font directories
if (entry.IsDirectory()) {
if (entry.GetNodeRef(&nodeRef) == B_OK
&& (directory = _FindDirectory(nodeRef)) != NULL)
_RemoveDirectory(directory);
} else {
// remove font style from directory
_RemoveStyle(nodeRef.device, fromNode, node);
}
}
break;
}
case B_ENTRY_REMOVED:
{
node_ref nodeRef;
uint64 directoryNode;
if (message->FindInt32("device", &nodeRef.device) != B_OK
|| message->FindInt64("directory", (int64 *)&directoryNode) != B_OK
|| message->FindInt64("node", &nodeRef.node) != B_OK)
break;
font_directory* directory = _FindDirectory(nodeRef);
if (directory != NULL) {
// the directory has been removed, so we remove it as well
_RemoveDirectory(directory);
} else {
// remove font style from directory
_RemoveStyle(nodeRef.device, directoryNode, nodeRef.node);
}
break;
}
}
break;
}
}
}