The DataEditor now has a separate entry_ref for attributes - that's used
to have access to the attributes of a root directory. Internally, only this ref is used when accessing attribute data. Also fixed an initialization bug in case the stream couldn't be properly opened; some values were just set too late (could lead to strange things as well as a crash). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10481 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -399,17 +399,21 @@ status_t
|
|||||||
DataEditor::SetTo(BEntry &entry, const char *attribute)
|
DataEditor::SetTo(BEntry &entry, const char *attribute)
|
||||||
{
|
{
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
|
fLastChange = fFirstChange = NULL;
|
||||||
|
fChangesFromSaved = 0;
|
||||||
|
fView = NULL;
|
||||||
|
fRealViewOffset = 0;
|
||||||
|
fViewOffset = 0;
|
||||||
|
fRealViewSize = fViewSize = fBlockSize = 512;
|
||||||
|
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
stat.st_mode = 0;
|
|
||||||
|
|
||||||
status_t status = entry.GetStat(&stat);
|
status_t status = entry.GetStat(&stat);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
bool isFileSystem = false;
|
entry.GetRef(&fAttributeRef);
|
||||||
|
|
||||||
fBlockSize = 512;
|
bool isFileSystem = false;
|
||||||
|
|
||||||
if (entry.IsDirectory()) {
|
if (entry.IsDirectory()) {
|
||||||
// we redirect root directories to their volumes
|
// we redirect root directories to their volumes
|
||||||
@@ -443,7 +447,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
fIsReadOnly = false;
|
fIsReadOnly = false;
|
||||||
|
|
||||||
entry.GetRef(&fRef);
|
entry.GetRef(&fRef);
|
||||||
|
|
||||||
fIsDevice = S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
fIsDevice = S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
||||||
|
|
||||||
if (attribute != NULL)
|
if (attribute != NULL)
|
||||||
@@ -452,8 +455,9 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
fAttribute = NULL;
|
fAttribute = NULL;
|
||||||
|
|
||||||
if (IsAttribute()) {
|
if (IsAttribute()) {
|
||||||
|
BNode node(&fAttributeRef);
|
||||||
attr_info info;
|
attr_info info;
|
||||||
status = fFile.GetAttrInfo(fAttribute, &info);
|
status = node.GetAttrInfo(fAttribute, &info);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
fFile.Unset();
|
fFile.Unset();
|
||||||
return status;
|
return status;
|
||||||
@@ -488,11 +492,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fLastChange = fFirstChange = NULL;
|
|
||||||
fChangesFromSaved = 0;
|
|
||||||
fView = NULL;
|
|
||||||
fRealViewOffset = 0;
|
|
||||||
fViewOffset = 0;
|
|
||||||
fRealViewSize = fViewSize = fBlockSize;
|
fRealViewSize = fViewSize = fBlockSize;
|
||||||
fNeedsUpdate = true;
|
fNeedsUpdate = true;
|
||||||
|
|
||||||
@@ -921,9 +920,10 @@ status_t
|
|||||||
DataEditor::Update()
|
DataEditor::Update()
|
||||||
{
|
{
|
||||||
ssize_t bytesRead;
|
ssize_t bytesRead;
|
||||||
if (IsAttribute())
|
if (IsAttribute()) {
|
||||||
bytesRead = fFile.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize);
|
BNode node(&fAttributeRef);
|
||||||
else
|
bytesRead = node.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize);
|
||||||
|
} else
|
||||||
bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
|
bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
|
||||||
|
|
||||||
if (bytesRead < B_OK)
|
if (bytesRead < B_OK)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef DATA_EDITOR_H
|
#ifndef DATA_EDITOR_H
|
||||||
#define DATA_EDITOR_H
|
#define DATA_EDITOR_H
|
||||||
@@ -78,6 +78,7 @@ class DataEditor : public BLocker {
|
|||||||
BMessenger progressMessenger, volatile bool *stop = NULL);
|
BMessenger progressMessenger, volatile bool *stop = NULL);
|
||||||
|
|
||||||
BFile &File() { return fFile; }
|
BFile &File() { return fFile; }
|
||||||
|
const entry_ref &AttributeRef() const { return fAttributeRef; }
|
||||||
const entry_ref &Ref() const { return fRef; }
|
const entry_ref &Ref() const { return fRef; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -94,7 +95,7 @@ class DataEditor : public BLocker {
|
|||||||
|
|
||||||
BObjectList<BMessenger> fObservers;
|
BObjectList<BMessenger> fObservers;
|
||||||
|
|
||||||
entry_ref fRef;
|
entry_ref fRef, fAttributeRef;
|
||||||
BFile fFile;
|
BFile fFile;
|
||||||
const char *fAttribute;
|
const char *fAttribute;
|
||||||
type_code fType;
|
type_code fType;
|
||||||
|
|||||||
Reference in New Issue
Block a user