From 54df6d4d663c2f28965103e61e4bcfb3f40e2da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 27 Feb 2004 21:45:31 +0000 Subject: [PATCH] Probe() now resolves symlinks, and longer accepts directories. It also won't try to open the file read-only anymore. RefsReceived() now opens an alert explaining the reason if Probe() fails. Slightly changed the about requester. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6784 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DiskProbe.cpp | 36 +++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/apps/diskprobe/DiskProbe.cpp b/src/apps/diskprobe/DiskProbe.cpp index c38ddbcaa5..6cc67190bd 100644 --- a/src/apps/diskprobe/DiskProbe.cpp +++ b/src/apps/diskprobe/DiskProbe.cpp @@ -243,11 +243,22 @@ DiskProbe::Probe(entry_ref &ref, const char *attribute) probeWindows++; } - // Does the file really exists? - BFile file; - status_t status = file.SetTo(&ref, B_READ_ONLY); + // Does the file really exist? + BEntry entry; + status_t status = entry.SetTo(&ref, true); if (status < B_OK) return status; + if (!entry.Exists()) + return B_ENTRY_NOT_FOUND; + + entry.GetRef(&ref); + + // If it's a directory, we won't handle it, but we would accept a volume + if (entry.IsDirectory()) { + BDirectory directory(&entry); + if (directory.InitCheck() != B_OK || !directory.IsRootDirectory()) + return B_IS_A_DIRECTORY; + } // cascade window BRect rect = fWindowFrame; @@ -275,7 +286,18 @@ DiskProbe::RefsReceived(BMessage *message) const char *attribute = NULL; message->FindString("attributes", index - 1, &attribute); - Probe(ref, attribute); + status_t status = Probe(ref, attribute); + if (status != B_OK) { + char buffer[1024]; + snprintf(buffer, sizeof(buffer), + "Could not open \"%s\":\n" + "%s", + ref.name, strerror(status)); + + (new BAlert("DiskProbe request", + buffer, "Ok", NULL, NULL, + B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); + } } } @@ -358,15 +380,15 @@ DiskProbe::AboutRequested() { BAlert *alert = new BAlert("about", "DiskProbe\n" "\twritten by Axel Dörfler\n" - "\tCopyright 2004, OpenBeOS.\n\n\n" - "original Be version by Robert Polic\n\n", "Ok"); + "\tCopyright 2004, OpenBeOS.\n\n" + "original Be version by Robert Polic\n", "Ok"); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); - font.SetSize(24); + font.SetSize(18); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, 9, &font);