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
This commit is contained in:
Axel Dörfler 2004-02-24 04:32:01 +00:00
parent a0858e6e27
commit 84a09d60e1
2 changed files with 22 additions and 10 deletions

View File

@ -9,6 +9,7 @@
#include <Autolock.h>
#include <NodeMonitor.h>
#include <Drivers.h>
#include <fs_attr.h>
#include <string.h>
#include <unistd.h>
@ -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;

View File

@ -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;