From 84a09d60e166b9a62412e4672e6645ec04beb49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 24 Feb 2004 04:32:01 +0000 Subject: [PATCH] No longer takes an attribute for a file, or a device for an attribute. Implemented attribute support. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6709 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DataEditor.cpp | 31 +++++++++++++++++++++---------- src/apps/diskprobe/DataEditor.h | 1 + 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 66d7a2c7cc..1272e0c602 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -203,9 +204,22 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) fFile.GetStat(&stat); fIsDevice = (stat.st_mode & (S_IFBLK | S_IFCHR)) != 0; + if (attribute != NULL) + fAttribute = strdup(attribute); + else + fAttribute = NULL; + fBlockSize = 512; - if (fIsDevice) { + if (IsAttribute()) { + attr_info info; + status = fFile.GetAttrInfo(fAttribute, &info); + if (status != B_OK) + return status; + + fSize = info.size; + fType = info.type; + } else if (fIsDevice) { // ToDo: is there any other possibility to issue a ioctl() from a BFile? device_geometry geometry; int device = fFile.Dup(); @@ -220,9 +234,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) fSize = 1LL * geometry.head_count * geometry.cylinder_count * geometry.sectors_per_track * geometry.bytes_per_sector; fBlockSize = geometry.bytes_per_sector; - } else if (IsAttribute()) { - // ToDo: add support for attributes! - fSize = 0; } else { status = fFile.GetSize(&fSize); if (status < B_OK) { @@ -231,11 +242,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute) } } - if (attribute != NULL) - fAttribute = strdup(attribute); - else - fAttribute = NULL; - fView = NULL; fRealViewOffset = 0; fViewOffset = 0; @@ -476,7 +482,12 @@ DataEditor::SetBlockSize(size_t size) status_t DataEditor::Update() { - ssize_t bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize); + ssize_t bytesRead; + if (IsAttribute()) + bytesRead = fFile.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize); + else + bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize); + if (bytesRead < B_OK) return bytesRead; diff --git a/src/apps/diskprobe/DataEditor.h b/src/apps/diskprobe/DataEditor.h index 8e19e4f6b3..ee2210bfbc 100644 --- a/src/apps/diskprobe/DataEditor.h +++ b/src/apps/diskprobe/DataEditor.h @@ -84,6 +84,7 @@ class DataEditor : public BLocker { entry_ref fRef; BFile fFile; const char *fAttribute; + type_code fType; bool fIsDevice, fIsReadOnly; off_t fRealSize, fSize;