As suggested by Rene and Jerome, switch to BDirectory::Contains(),
which is way cleaner. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39806 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -158,14 +158,14 @@ class TrashMonitor : public BHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opcode == B_ENTRY_MOVED) {
|
if (opcode == B_ENTRY_MOVED) {
|
||||||
entry_ref entry;
|
entry_ref ref;
|
||||||
const char* name;
|
const char* name;
|
||||||
msg->FindInt64("to directory", &entry.directory);
|
msg->FindInt64("to directory", &ref.directory);
|
||||||
msg->FindInt32("device", &entry.device);
|
msg->FindInt32("device", &ref.device);
|
||||||
msg->FindString("name", &name);
|
msg->FindString("name", &name);
|
||||||
entry.set_name(name);
|
ref.set_name(name);
|
||||||
|
|
||||||
BNode node(&entry);
|
BNode node(&ref);
|
||||||
int32 chain;
|
int32 chain;
|
||||||
|
|
||||||
// check it's a mail
|
// check it's a mail
|
||||||
@@ -179,7 +179,7 @@ class TrashMonitor : public BHandler {
|
|||||||
// check if it was moved to trash
|
// check if it was moved to trash
|
||||||
bool moved_to_trash = false;
|
bool moved_to_trash = false;
|
||||||
BPath trashPath;
|
BPath trashPath;
|
||||||
BPath entryPath(&entry);
|
BEntry entry(&ref);
|
||||||
BVolumeRoster volumes;
|
BVolumeRoster volumes;
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
while (volumes.GetNextVolume(&volume) == B_OK) {
|
while (volumes.GetNextVolume(&volume) == B_OK) {
|
||||||
@@ -189,8 +189,8 @@ class TrashMonitor : public BHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(entryPath.Path(), trashPath.Path(),
|
BDirectory trash(trashPath.Path());
|
||||||
strlen(trashPath.Path())) == 0) {
|
if (trash.Contains(&entry)) {
|
||||||
moved_to_trash = true;
|
moved_to_trash = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,22 +126,17 @@ void DeskbarView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DeskbarView::_EntryInTrash(const entry_ref* entry)
|
bool DeskbarView::_EntryInTrash(const entry_ref* ref)
|
||||||
{
|
{
|
||||||
BPath trashPath;
|
BEntry entry(ref);
|
||||||
BPath entryPath(entry);
|
BVolume volume(ref->device);
|
||||||
BVolume volume(entry->device);
|
BPath path;
|
||||||
if (volume.InitCheck() == B_OK
|
if (volume.InitCheck() != B_OK
|
||||||
&& find_directory(B_TRASH_DIRECTORY, &trashPath, false,
|
|| find_directory(B_TRASH_DIRECTORY, &path, false, &volume) != B_OK)
|
||||||
&volume) == B_OK) {
|
return false;
|
||||||
char path[PATH_MAX];
|
|
||||||
strncpy(path, trashPath.Path(), sizeof(path));
|
|
||||||
strncat(path, "/", sizeof(path));
|
|
||||||
if (strncmp(entryPath.Path(), path, strlen(path)) == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
BDirectory trash(path.Path());
|
||||||
|
return trash.Contains(&entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <ChainRunner.h>
|
#include <ChainRunner.h>
|
||||||
#include <Deskbar.h>
|
#include <Deskbar.h>
|
||||||
|
#include <Directory.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <fs_index.h>
|
#include <fs_index.h>
|
||||||
@@ -633,22 +634,16 @@ bool
|
|||||||
MailDaemonApp::_IsEntryInTrash(BEntry& entry)
|
MailDaemonApp::_IsEntryInTrash(BEntry& entry)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
|
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
BPath trashPath;
|
|
||||||
BPath entryPath(&entry);
|
|
||||||
BVolume volume(ref.device);
|
|
||||||
if (volume.InitCheck() == B_OK
|
|
||||||
&& find_directory(B_TRASH_DIRECTORY, &trashPath,
|
|
||||||
false, &volume) == B_OK) {
|
|
||||||
char path[PATH_MAX];
|
|
||||||
strncpy(path, trashPath.Path(), sizeof(path));
|
|
||||||
strncat(path, "/", sizeof(path));
|
|
||||||
if (strncmp(entryPath.Path(), path, strlen(path)) == 0)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
BVolume volume(ref.device);
|
||||||
|
BPath path;
|
||||||
|
if (volume.InitCheck() != B_OK
|
||||||
|
|| find_directory(B_TRASH_DIRECTORY, &path, false, &volume) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BDirectory trash(path.Path());
|
||||||
|
return trash.Contains(&entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user