From 86daa6f28cc8d51d41a2c6227f4756e0780c67f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 17 Dec 2004 08:37:50 +0000 Subject: [PATCH] Now also shows the volume name instead of the entry_ref name for root directories. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10482 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/AttributeWindow.cpp | 34 +++++++++++++++++++++----- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/apps/diskprobe/AttributeWindow.cpp b/src/apps/diskprobe/AttributeWindow.cpp index 89f50729de..43e636060f 100644 --- a/src/apps/diskprobe/AttributeWindow.cpp +++ b/src/apps/diskprobe/AttributeWindow.cpp @@ -1,7 +1,7 @@ -/* -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ +/* + * Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include "AttributeWindow.h" @@ -13,6 +13,8 @@ #include #include #include +#include +#include static const uint32 kMsgRemoveAttribute = 'rmat'; @@ -171,8 +173,28 @@ AttributeWindow::AttributeWindow(BRect rect, entry_ref *ref, const char *attribu : ProbeWindow(rect, ref), fAttribute(strdup(attribute)) { - char buffer[256]; - snprintf(buffer, sizeof(buffer), "%s: %s", ref->name, attribute); + // Set alternative window title for devices + + char name[B_FILE_NAME_LENGTH]; +#ifdef COMPILE_FOR_R5 + strncpy(name, ref->name, sizeof(name)); + name[sizeof(name) - 1] = '\0'; +#else + strlcpy(name, ref->name, sizeof(name)); +#endif + + BEntry entry(ref); + if (entry.IsDirectory()) { + BDirectory directory(&entry); + if (directory.InitCheck() == B_OK && directory.IsRootDirectory()) { + // use the volume name for root directories + BVolume volume; + if (directory.GetVolume(&volume) == B_OK) + volume.GetName(name); + } + } + char buffer[B_PATH_NAME_LENGTH]; + snprintf(buffer, sizeof(buffer), "%s: %s", name, attribute); SetTitle(buffer); // add the menu