* Don't even try to use the BeOS compatible types on the build platform.
That's just leading to problems. * Fixed various 64 bit warnings when building libbe_build.so. One of the more serious issues, that might bite us, is that 64 bit Linux defines dev_t to unsigned long, while Haiku code assumes that it is signed and 32 bit. We'll see... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34227 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,18 +53,4 @@
|
|||||||
#define __HAIKU_SUBDIR_ARCH_HEADER(subdir, header) \
|
#define __HAIKU_SUBDIR_ARCH_HEADER(subdir, header) \
|
||||||
<subdir/arch/__HAIKU_ARCH/header>
|
<subdir/arch/__HAIKU_ARCH/header>
|
||||||
|
|
||||||
/* BeOS R5 binary compatibility (gcc 2 on x86) */
|
|
||||||
#if defined(__HAIKU_ARCH_X86) && __GNUC__ == 2
|
|
||||||
# define __HAIKU_BEOS_COMPATIBLE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* BeOS R5 compatible types */
|
|
||||||
#ifdef __HAIKU_ARCH_X86
|
|
||||||
/* TODO: This should be "#ifdef __HAIKU_BEOS_COMPATIBLE", but this will
|
|
||||||
break all gcc 4 C++ optional packages. I.e. switch that at a suitable
|
|
||||||
time.
|
|
||||||
*/
|
|
||||||
# define __HAIKU_BEOS_COMPATIBLE_TYPES 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _CONFIG_HAIKU_CONFIG_H */
|
#endif /* _CONFIG_HAIKU_CONFIG_H */
|
||||||
|
|||||||
@@ -29,13 +29,8 @@ typedef __haiku_std_int8 __haiku_int8;
|
|||||||
typedef __haiku_std_uint8 __haiku_uint8;
|
typedef __haiku_std_uint8 __haiku_uint8;
|
||||||
typedef __haiku_std_int16 __haiku_int16;
|
typedef __haiku_std_int16 __haiku_int16;
|
||||||
typedef __haiku_std_uint16 __haiku_uint16;
|
typedef __haiku_std_uint16 __haiku_uint16;
|
||||||
#ifdef __HAIKU_BEOS_COMPATIBLE_TYPES
|
|
||||||
typedef signed long int __haiku_int32;
|
|
||||||
typedef unsigned long int __haiku_uint32;
|
|
||||||
#else
|
|
||||||
typedef __haiku_std_int32 __haiku_int32;
|
typedef __haiku_std_int32 __haiku_int32;
|
||||||
typedef __haiku_std_uint32 __haiku_uint32;
|
typedef __haiku_std_uint32 __haiku_uint32;
|
||||||
#endif
|
|
||||||
typedef __haiku_std_int64 __haiku_int64;
|
typedef __haiku_std_int64 __haiku_int64;
|
||||||
typedef __haiku_std_uint64 __haiku_uint64;
|
typedef __haiku_std_uint64 __haiku_uint64;
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
if (isprint(*(char *)&value)) {
|
if (isprint(*(char *)&value)) {
|
||||||
printf("'%.4s'", (char *)&value);
|
printf("'%.4s'", (char *)&value);
|
||||||
} else
|
} else
|
||||||
printf("0x%lx", what);
|
printf("0x%" B_PRIx32, what);
|
||||||
printf(") {\n");
|
printf(") {\n");
|
||||||
|
|
||||||
field_header *field = fFields;
|
field_header *field = fFields;
|
||||||
@@ -369,7 +369,7 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
printf("%s %s = ", indent,
|
printf("%s %s = ", indent,
|
||||||
(char *)(fData + field->offset));
|
(char *)(fData + field->offset));
|
||||||
} else {
|
} else {
|
||||||
printf("%s %s[%ld] = ", indent,
|
printf("%s %s[%" B_PRId32 "] = ", indent,
|
||||||
(char *)(fData + field->offset), j);
|
(char *)(fData + field->offset), j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,8 +426,9 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
BPrivate::entry_ref_unflatten(&ref, (char *)pointer, size);
|
BPrivate::entry_ref_unflatten(&ref, (char *)pointer, size);
|
||||||
|
|
||||||
printf("entry_ref(device=%ld, directory=%lld, name=\"%s\", ",
|
printf("entry_ref(device=%ld, directory=%" B_PRIdINO
|
||||||
(long)ref.device, ref.directory, ref.name);
|
", name=\"%s\", ", (long)ref.device, ref.directory,
|
||||||
|
ref.name);
|
||||||
|
|
||||||
BPath path(&ref);
|
BPath path(&ref);
|
||||||
printf("path=\"%s\")\n", path.Path());
|
printf("path=\"%s\")\n", path.Path());
|
||||||
@@ -444,7 +445,8 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
const ssize_t size = *(const ssize_t *)pointer;
|
const ssize_t size = *(const ssize_t *)pointer;
|
||||||
pointer += sizeof(ssize_t);
|
pointer += sizeof(ssize_t);
|
||||||
if (message.Unflatten((const char *)pointer) != B_OK) {
|
if (message.Unflatten((const char *)pointer) != B_OK) {
|
||||||
fprintf(stderr, "couldn't unflatten item %ld\n", i);
|
fprintf(stderr, "couldn't unflatten item %" B_PRId32
|
||||||
|
"\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
message._PrintToStream(buffer);
|
message._PrintToStream(buffer);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ entry_ref_unflatten(entry_ref *ref, const char *buffer, size_t size)
|
|||||||
memcpy((void *)&ref->directory, (const void *)buffer, sizeof(ref->directory));
|
memcpy((void *)&ref->directory, (const void *)buffer, sizeof(ref->directory));
|
||||||
buffer += sizeof(ref->directory);
|
buffer += sizeof(ref->directory);
|
||||||
|
|
||||||
if (ref->device != -1 && size > sizeof(ref->device)
|
if (ref->device != ~(dev_t)0 && size > sizeof(ref->device)
|
||||||
+ sizeof(ref->directory)) {
|
+ sizeof(ref->directory)) {
|
||||||
ref->set_name(buffer);
|
ref->set_name(buffer);
|
||||||
if (ref->name == NULL) {
|
if (ref->name == NULL) {
|
||||||
|
|||||||
@@ -1223,7 +1223,8 @@ set_bits_worker_gray1(const void *inData, int32 inLength, int32 inBPR,
|
|||||||
- (inBPR - inRowSkip);
|
- (inBPR - inRowSkip);
|
||||||
const char *outEnd = (const char*)outData + outLength - outBPR;
|
const char *outEnd = (const char*)outData + outLength - outBPR;
|
||||||
char *outRow = (char*)outData + outOffset - outOffset % outBPR;
|
char *outRow = (char*)outData + outOffset - outOffset % outBPR;
|
||||||
int32 x = max(0L, width - ((char*)outData + outOffset - outRow) * 8) - 1;
|
int32 x = max((int32)0,
|
||||||
|
width - (int32)((char*)outData + outOffset - outRow) * 8) - 1;
|
||||||
while ((const char*)reader.pixels <= inEnd
|
while ((const char*)reader.pixels <= inEnd
|
||||||
&& (const char*)writer.pixels <= outEnd) {
|
&& (const char*)writer.pixels <= outEnd) {
|
||||||
// process one row
|
// process one row
|
||||||
@@ -1532,36 +1533,36 @@ BBitmap::BBitmap(BMessage *data)
|
|||||||
{
|
{
|
||||||
BRect bounds;
|
BRect bounds;
|
||||||
data->FindRect("_frame", &bounds);
|
data->FindRect("_frame", &bounds);
|
||||||
|
|
||||||
color_space cspace;
|
color_space cspace;
|
||||||
data->FindInt32("_cspace", (int32 *)&cspace);
|
data->FindInt32("_cspace", (int32 *)&cspace);
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
data->FindInt32("_bmflags", &flags);
|
data->FindInt32("_bmflags", &flags);
|
||||||
|
|
||||||
int32 rowbytes = 0;
|
int32 rowbytes = 0;
|
||||||
data->FindInt32("_rowbytes", &rowbytes);
|
data->FindInt32("_rowbytes", &rowbytes);
|
||||||
|
|
||||||
flags |= B_BITMAP_NO_SERVER_LINK;
|
flags |= B_BITMAP_NO_SERVER_LINK;
|
||||||
flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
||||||
InitObject(bounds, cspace, flags, rowbytes, B_MAIN_SCREEN_ID);
|
InitObject(bounds, cspace, flags, rowbytes, B_MAIN_SCREEN_ID);
|
||||||
|
|
||||||
if (data->HasData("_data", B_RAW_TYPE) && InitCheck() == B_OK) {
|
if (data->HasData("_data", B_RAW_TYPE) && InitCheck() == B_OK) {
|
||||||
ssize_t size = 0;
|
ssize_t size = 0;
|
||||||
const void *buffer;
|
const void *buffer;
|
||||||
if (data->FindData("_data", B_RAW_TYPE, &buffer, &size) == B_OK)
|
if (data->FindData("_data", B_RAW_TYPE, &buffer, &size) == B_OK)
|
||||||
memcpy(fBasePtr, buffer, size);
|
memcpy(fBasePtr, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
|
if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
|
||||||
// BArchivable *obj;
|
// BArchivable *obj;
|
||||||
// BMessage message;
|
// BMessage message;
|
||||||
// int i = 0;
|
// int i = 0;
|
||||||
//
|
//
|
||||||
// while (data->FindMessage("_view", i++, &message) == B_OK) {
|
// while (data->FindMessage("_view", i++, &message) == B_OK) {
|
||||||
// obj = instantiate_object(&message);
|
// obj = instantiate_object(&message);
|
||||||
// BView *view = dynamic_cast<BView *>(obj);
|
// BView *view = dynamic_cast<BView *>(obj);
|
||||||
//
|
//
|
||||||
// if (view)
|
// if (view)
|
||||||
// AddChild(view);
|
// AddChild(view);
|
||||||
// }
|
// }
|
||||||
@@ -1579,7 +1580,7 @@ BBitmap::Instantiate(BMessage *data)
|
|||||||
{
|
{
|
||||||
if (validate_instantiation(data, "BBitmap"))
|
if (validate_instantiation(data, "BBitmap"))
|
||||||
return new BBitmap(data);
|
return new BBitmap(data);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1594,12 +1595,12 @@ status_t
|
|||||||
BBitmap::Archive(BMessage *data, bool deep) const
|
BBitmap::Archive(BMessage *data, bool deep) const
|
||||||
{
|
{
|
||||||
BArchivable::Archive(data, deep);
|
BArchivable::Archive(data, deep);
|
||||||
|
|
||||||
data->AddRect("_frame", fBounds);
|
data->AddRect("_frame", fBounds);
|
||||||
data->AddInt32("_cspace", (int32)fColorSpace);
|
data->AddInt32("_cspace", (int32)fColorSpace);
|
||||||
data->AddInt32("_bmflags", fFlags);
|
data->AddInt32("_bmflags", fFlags);
|
||||||
data->AddInt32("_rowbytes", fBytesPerRow);
|
data->AddInt32("_rowbytes", fBytesPerRow);
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
|
if (fFlags & B_BITMAP_ACCEPTS_VIEWS) {
|
||||||
// BMessage views;
|
// BMessage views;
|
||||||
@@ -1612,10 +1613,10 @@ BBitmap::Archive(BMessage *data, bool deep) const
|
|||||||
// true and it does save all formats as B_RAW_TYPE and it does save
|
// true and it does save all formats as B_RAW_TYPE and it does save
|
||||||
// the data even if B_BITMAP_ACCEPTS_VIEWS is set (as opposed to
|
// the data even if B_BITMAP_ACCEPTS_VIEWS is set (as opposed to
|
||||||
// the BeBook)
|
// the BeBook)
|
||||||
|
|
||||||
data->AddData("_data", B_RAW_TYPE, fBasePtr, fSize);
|
data->AddData("_data", B_RAW_TYPE, fBasePtr, fSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1796,7 +1797,7 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr, int32 offset,
|
|||||||
color_space colorSpace)
|
color_space colorSpace)
|
||||||
{
|
{
|
||||||
status_t error = (InitCheck() == B_OK ? B_OK : B_NO_INIT);
|
status_t error = (InitCheck() == B_OK ? B_OK : B_NO_INIT);
|
||||||
// check params
|
// check params
|
||||||
if (error == B_OK && (data == NULL || offset > fSize || length < 0))
|
if (error == B_OK && (data == NULL || offset > fSize || length < 0))
|
||||||
error = B_BAD_VALUE;
|
error = B_BAD_VALUE;
|
||||||
// get BPR
|
// get BPR
|
||||||
@@ -2080,8 +2081,8 @@ flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
|||||||
} else {
|
} else {
|
||||||
// // Ask the server (via our owning application) to create a bitmap.
|
// // Ask the server (via our owning application) to create a bitmap.
|
||||||
// BPrivate::AppServerLink link;
|
// BPrivate::AppServerLink link;
|
||||||
//
|
//
|
||||||
// // Attach Data:
|
// // Attach Data:
|
||||||
// // 1) BRect bounds
|
// // 1) BRect bounds
|
||||||
// // 2) color_space space
|
// // 2) color_space space
|
||||||
// // 3) int32 bitmap_flags
|
// // 3) int32 bitmap_flags
|
||||||
@@ -2093,20 +2094,20 @@ flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
|||||||
// link.Attach<int32>((int32)flags);
|
// link.Attach<int32>((int32)flags);
|
||||||
// link.Attach<int32>(bytesPerRow);
|
// link.Attach<int32>(bytesPerRow);
|
||||||
// link.Attach<int32>(screenID.id);
|
// link.Attach<int32>(screenID.id);
|
||||||
//
|
//
|
||||||
// // Reply Code: SERVER_TRUE
|
// // Reply Code: SERVER_TRUE
|
||||||
// // Reply Data:
|
// // Reply Data:
|
||||||
// // 1) int32 server token
|
// // 1) int32 server token
|
||||||
// // 2) area_id id of the area in which the bitmap data resides
|
// // 2) area_id id of the area in which the bitmap data resides
|
||||||
// // 3) int32 area pointer offset used to calculate fBasePtr
|
// // 3) int32 area pointer offset used to calculate fBasePtr
|
||||||
//
|
//
|
||||||
// // alternatively, if something went wrong
|
// // alternatively, if something went wrong
|
||||||
// // Reply Code: SERVER_FALSE
|
// // Reply Code: SERVER_FALSE
|
||||||
// // Reply Data:
|
// // Reply Data:
|
||||||
// // None
|
// // None
|
||||||
// int32 code = SERVER_FALSE;
|
// int32 code = SERVER_FALSE;
|
||||||
// error = link.FlushWithReply(code);
|
// error = link.FlushWithReply(code);
|
||||||
//
|
//
|
||||||
// if (error >= B_OK) {
|
// if (error >= B_OK) {
|
||||||
// // *communication* with server successful
|
// // *communication* with server successful
|
||||||
// if (code == SERVER_TRUE) {
|
// if (code == SERVER_TRUE) {
|
||||||
@@ -2114,21 +2115,21 @@ flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
|||||||
// // Get token
|
// // Get token
|
||||||
// area_id bmparea;
|
// area_id bmparea;
|
||||||
// int32 areaoffset;
|
// int32 areaoffset;
|
||||||
//
|
//
|
||||||
// link.Read<int32>(&fServerToken);
|
// link.Read<int32>(&fServerToken);
|
||||||
// link.Read<area_id>(&bmparea);
|
// link.Read<area_id>(&bmparea);
|
||||||
// link.Read<int32>(&areaoffset);
|
// link.Read<int32>(&areaoffset);
|
||||||
//
|
//
|
||||||
// // Get the area in which the data resides
|
// // Get the area in which the data resides
|
||||||
// fArea = clone_area("shared bitmap area",
|
// fArea = clone_area("shared bitmap area",
|
||||||
// (void**)&fBasePtr,
|
// (void**)&fBasePtr,
|
||||||
// B_ANY_ADDRESS,
|
// B_ANY_ADDRESS,
|
||||||
// B_READ_AREA | B_WRITE_AREA,
|
// B_READ_AREA | B_WRITE_AREA,
|
||||||
// bmparea);
|
// bmparea);
|
||||||
//
|
//
|
||||||
// // Jump to the location in the area
|
// // Jump to the location in the area
|
||||||
// fBasePtr = (int8*)fBasePtr + areaoffset;
|
// fBasePtr = (int8*)fBasePtr + areaoffset;
|
||||||
//
|
//
|
||||||
// fSize = size;
|
// fSize = size;
|
||||||
// fColorSpace = colorSpace;
|
// fColorSpace = colorSpace;
|
||||||
// fBounds = bounds;
|
// fBounds = bounds;
|
||||||
@@ -2152,7 +2153,7 @@ flags &= ~B_BITMAP_ACCEPTS_VIEWS;
|
|||||||
fToken = -1;
|
fToken = -1;
|
||||||
fOrigArea = -1;
|
fOrigArea = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fInitError = error;
|
fInitError = error;
|
||||||
// TODO: on success, handle clearing to white if the flags say so. Needs to be
|
// TODO: on success, handle clearing to white if the flags say so. Needs to be
|
||||||
// dependent on color space.
|
// dependent on color space.
|
||||||
@@ -2181,10 +2182,10 @@ BBitmap::CleanUp()
|
|||||||
} else {
|
} else {
|
||||||
// BPrivate::AppServerLink link;
|
// BPrivate::AppServerLink link;
|
||||||
// // AS_DELETE_BITMAP:
|
// // AS_DELETE_BITMAP:
|
||||||
// // Attached Data:
|
// // Attached Data:
|
||||||
// // 1) int32 server token
|
// // 1) int32 server token
|
||||||
//
|
//
|
||||||
// // Reply Code: SERVER_TRUE if successful,
|
// // Reply Code: SERVER_TRUE if successful,
|
||||||
// // SERVER_FALSE if the buffer was already deleted
|
// // SERVER_FALSE if the buffer was already deleted
|
||||||
// // Reply Data: none
|
// // Reply Data: none
|
||||||
// // status_t freestat;
|
// // status_t freestat;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ BRegion::operator=(const BRegion ®ion)
|
|||||||
fBounds = region.fBounds;
|
fBounds = region.fBounds;
|
||||||
fCount = region.fCount;
|
fCount = region.fCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ BRegion::RectAt(int32 index) /*const*/
|
|||||||
const clipping_rect& r = fData[index];
|
const clipping_rect& r = fData[index];
|
||||||
return BRect(r.left, r.top, r.right - 1, r.bottom - 1);
|
return BRect(r.left, r.top, r.right - 1, r.bottom - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BRect();
|
return BRect();
|
||||||
// an invalid BRect
|
// an invalid BRect
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,8 @@ BRegion::PrintToStream() const
|
|||||||
|
|
||||||
for (long i = 0; i < fCount; i++) {
|
for (long i = 0; i < fCount; i++) {
|
||||||
clipping_rect *rect = &fData[i];
|
clipping_rect *rect = &fData[i];
|
||||||
printf("data[%ld] = BRect(l:%ld.0, t:%ld.0, r:%ld.0, b:%ld.0)\n",
|
printf("data[%ld] = BRect(l:%" B_PRId32 ".0, t:%" B_PRId32 ".0, r:%"
|
||||||
|
B_PRId32 ".0, b:%" B_PRId32 ".0)\n",
|
||||||
i, rect->left, rect->top, rect->right - 1, rect->bottom - 1);
|
i, rect->left, rect->top, rect->right - 1, rect->bottom - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -489,7 +490,7 @@ BRegion::_SetSize(long newSize)
|
|||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fData) {
|
if (!fData) {
|
||||||
// allocation actually failed
|
// allocation actually failed
|
||||||
fDataSize = 0;
|
fDataSize = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// This software is part of the Haiku distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the MIT license.
|
// by the MIT license.
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
@@ -51,7 +51,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// R5 also exports these (Tracker is using them):
|
// R5 also exports these (Tracker is using them):
|
||||||
// (maybe we better want to drop them silently and declare
|
// (maybe we better want to drop them silently and declare
|
||||||
// the above in a public Haiku header - and use that one in
|
// the above in a public Haiku header - and use that one in
|
||||||
// Tracker when compiled for Haiku)
|
// Tracker when compiled for Haiku)
|
||||||
extern const uint32 MINI_ICON_TYPE, LARGE_ICON_TYPE;
|
extern const uint32 MINI_ICON_TYPE, LARGE_ICON_TYPE;
|
||||||
@@ -675,7 +675,7 @@ BAppFileInfo::GetVersionInfo(version_info *info, version_kind kind) const
|
|||||||
} else
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1065,7 +1065,7 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
size_t &bytesRead, void **allocatedBuffer) const
|
size_t &bytesRead, void **allocatedBuffer) const
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
if (allocatedBuffer)
|
if (allocatedBuffer)
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
|
||||||
@@ -1086,7 +1086,7 @@ BAppFileInfo::_ReadData(const char *name, int32 id, type_code type,
|
|||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
bufferSize = info.size;
|
bufferSize = info.size;
|
||||||
}
|
}
|
||||||
if (error == B_OK && bufferSize < info.size)
|
if (error == B_OK && (off_t)bufferSize < info.size)
|
||||||
error = B_BAD_VALUE;
|
error = B_BAD_VALUE;
|
||||||
|
|
||||||
// read the data
|
// read the data
|
||||||
|
|||||||
@@ -41,19 +41,19 @@ using namespace std;
|
|||||||
|
|
||||||
/*! \struct entry_ref
|
/*! \struct entry_ref
|
||||||
\brief A filesystem entry represented as a name in a concrete directory.
|
\brief A filesystem entry represented as a name in a concrete directory.
|
||||||
|
|
||||||
entry_refs may refer to pre-existing (concrete) files, as well as non-existing
|
entry_refs may refer to pre-existing (concrete) files, as well as non-existing
|
||||||
(abstract) files. However, the parent directory of the file \b must exist.
|
(abstract) files. However, the parent directory of the file \b must exist.
|
||||||
|
|
||||||
The result of this dichotomy is a blending of the persistence gained by referring
|
The result of this dichotomy is a blending of the persistence gained by referring
|
||||||
to entries with a reference to their internal filesystem node and the flexibility gained
|
to entries with a reference to their internal filesystem node and the flexibility gained
|
||||||
by referring to entries by name.
|
by referring to entries by name.
|
||||||
|
|
||||||
For example, if the directory in which the entry resides (or a
|
For example, if the directory in which the entry resides (or a
|
||||||
directory further up in the hierarchy) is moved or renamed, the entry_ref will
|
directory further up in the hierarchy) is moved or renamed, the entry_ref will
|
||||||
still refer to the correct file (whereas a pathname to the previous location of the
|
still refer to the correct file (whereas a pathname to the previous location of the
|
||||||
file would now be invalid).
|
file would now be invalid).
|
||||||
|
|
||||||
On the other hand, say that the entry_ref refers to a concrete file. If the file
|
On the other hand, say that the entry_ref refers to a concrete file. If the file
|
||||||
itself is renamed, the entry_ref now refers to an abstract file with the old name
|
itself is renamed, the entry_ref now refers to an abstract file with the old name
|
||||||
(the upside in this case is that abstract entries may be represented by entry_refs
|
(the upside in this case is that abstract entries may be represented by entry_refs
|
||||||
@@ -61,7 +61,7 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Creates an unitialized entry_ref.
|
//! Creates an unitialized entry_ref.
|
||||||
entry_ref::entry_ref()
|
entry_ref::entry_ref()
|
||||||
:
|
:
|
||||||
device((dev_t)-1),
|
device((dev_t)-1),
|
||||||
@@ -73,12 +73,12 @@ entry_ref::entry_ref()
|
|||||||
|
|
||||||
/*! \brief Creates an entry_ref initialized to the given file name in the given
|
/*! \brief Creates an entry_ref initialized to the given file name in the given
|
||||||
directory on the given device.
|
directory on the given device.
|
||||||
|
|
||||||
\p name may refer to either a pre-existing file in the given
|
\p name may refer to either a pre-existing file in the given
|
||||||
directory, or a non-existent file. No explicit checking is done to verify validity of the given arguments, but
|
directory, or a non-existent file. No explicit checking is done to verify validity of the given arguments, but
|
||||||
later use of the entry_ref will fail if \p dev is not a valid device or \p dir
|
later use of the entry_ref will fail if \p dev is not a valid device or \p dir
|
||||||
is a not a directory on \p dev.
|
is a not a directory on \p dev.
|
||||||
|
|
||||||
\param dev the device on which the entry's parent directory resides
|
\param dev the device on which the entry's parent directory resides
|
||||||
\param dir the directory in which the entry resides
|
\param dir the directory in which the entry resides
|
||||||
\param name the leaf name of the entry, which is not required to exist
|
\param name the leaf name of the entry, which is not required to exist
|
||||||
@@ -102,12 +102,12 @@ entry_ref::entry_ref(const entry_ref &ref)
|
|||||||
directory(ref.directory),
|
directory(ref.directory),
|
||||||
name(NULL)
|
name(NULL)
|
||||||
{
|
{
|
||||||
set_name(ref.name);
|
set_name(ref.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Destroys the object and frees the storage allocated for the leaf name,
|
/*! Destroys the object and frees the storage allocated for the leaf name,
|
||||||
if necessary.
|
if necessary.
|
||||||
*/
|
*/
|
||||||
entry_ref::~entry_ref()
|
entry_ref::~entry_ref()
|
||||||
{
|
{
|
||||||
@@ -117,7 +117,7 @@ entry_ref::~entry_ref()
|
|||||||
|
|
||||||
/*! \brief Set the entry_ref's leaf name, freeing the storage allocated for any previous
|
/*! \brief Set the entry_ref's leaf name, freeing the storage allocated for any previous
|
||||||
name and then making a copy of the new name.
|
name and then making a copy of the new name.
|
||||||
|
|
||||||
\param name pointer to a null-terminated string containing the new name for
|
\param name pointer to a null-terminated string containing the new name for
|
||||||
the entry. May be \c NULL.
|
the entry. May be \c NULL.
|
||||||
*/
|
*/
|
||||||
@@ -134,7 +134,7 @@ entry_ref::set_name(const char *newName)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ entry_ref&
|
|||||||
entry_ref::operator=(const entry_ref &ref)
|
entry_ref::operator=(const entry_ref &ref)
|
||||||
{
|
{
|
||||||
if (this == &ref)
|
if (this == &ref)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
device = ref.device;
|
device = ref.device;
|
||||||
directory = ref.directory;
|
directory = ref.directory;
|
||||||
@@ -203,22 +203,22 @@ entry_ref::operator=(const entry_ref &ref)
|
|||||||
/*!
|
/*!
|
||||||
\class BEntry
|
\class BEntry
|
||||||
\brief A location in the filesystem
|
\brief A location in the filesystem
|
||||||
|
|
||||||
The BEntry class defines objects that represent "locations" in the file system
|
The BEntry class defines objects that represent "locations" in the file system
|
||||||
hierarchy. Each location (or entry) is given as a name within a directory. For
|
hierarchy. Each location (or entry) is given as a name within a directory. For
|
||||||
example, when you create a BEntry thus:
|
example, when you create a BEntry thus:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
BEntry entry("/boot/home/fido");
|
BEntry entry("/boot/home/fido");
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
...you're telling the BEntry object to represent the location of the file
|
...you're telling the BEntry object to represent the location of the file
|
||||||
called fido within the directory \c "/boot/home".
|
called fido within the directory \c "/boot/home".
|
||||||
|
|
||||||
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
|
\author <a href='mailto:bonefish@users.sf.net'>Ingo Weinhold</a>
|
||||||
\author <a href='mailto:tylerdauwalder@users.sf.net'>Tyler Dauwalder</a>
|
\author <a href='mailto:tylerdauwalder@users.sf.net'>Tyler Dauwalder</a>
|
||||||
\author <a href='mailto:scusack@users.sf.net'>Simon Cusack</a>
|
\author <a href='mailto:scusack@users.sf.net'>Simon Cusack</a>
|
||||||
|
|
||||||
\version 0.0.0
|
\version 0.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ BEntry::BEntry()
|
|||||||
//! Creates a BEntry initialized to the given directory and path combination.
|
//! Creates a BEntry initialized to the given directory and path combination.
|
||||||
/*! If traverse is true and \c dir/path refers to a symlink, the BEntry will
|
/*! If traverse is true and \c dir/path refers to a symlink, the BEntry will
|
||||||
refer to the linked file; if false, the BEntry will refer to the symlink itself.
|
refer to the linked file; if false, the BEntry will refer to the symlink itself.
|
||||||
|
|
||||||
\param dir directory in which \a path resides
|
\param dir directory in which \a path resides
|
||||||
\param path relative path reckoned off of \a dir
|
\param path relative path reckoned off of \a dir
|
||||||
\param traverse whether or not to traverse symlinks
|
\param traverse whether or not to traverse symlinks
|
||||||
@@ -267,7 +267,7 @@ BEntry::BEntry(const BDirectory *dir, const char *path, bool traverse)
|
|||||||
/*! If traverse is true and \a ref refers to a symlink, the BEntry
|
/*! If traverse is true and \a ref refers to a symlink, the BEntry
|
||||||
will refer to the linked file; if false, the BEntry will refer
|
will refer to the linked file; if false, the BEntry will refer
|
||||||
to the symlink itself.
|
to the symlink itself.
|
||||||
|
|
||||||
\param ref the entry_ref referring to the given file
|
\param ref the entry_ref referring to the given file
|
||||||
\param traverse whether or not symlinks are to be traversed
|
\param traverse whether or not symlinks are to be traversed
|
||||||
\see SetTo(const entry_ref*, bool)
|
\see SetTo(const entry_ref*, bool)
|
||||||
@@ -287,11 +287,11 @@ BEntry::BEntry(const entry_ref *ref, bool traverse)
|
|||||||
be reckoned off the current working directory. If \a path refers to a symlink and
|
be reckoned off the current working directory. If \a path refers to a symlink and
|
||||||
traverse is true, the BEntry will refer to the linked file. If traverse is false,
|
traverse is true, the BEntry will refer to the linked file. If traverse is false,
|
||||||
the BEntry will refer to the symlink itself.
|
the BEntry will refer to the symlink itself.
|
||||||
|
|
||||||
\param path the file of interest
|
\param path the file of interest
|
||||||
\param traverse whether or not symlinks are to be traversed
|
\param traverse whether or not symlinks are to be traversed
|
||||||
\see SetTo(const char*, bool)
|
\see SetTo(const char*, bool)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
BEntry::BEntry(const char *path, bool traverse)
|
BEntry::BEntry(const char *path, bool traverse)
|
||||||
:
|
:
|
||||||
@@ -354,10 +354,10 @@ BEntry::Exists() const
|
|||||||
|
|
||||||
/*! \brief Fills in a stat structure for the entry. The information is copied into
|
/*! \brief Fills in a stat structure for the entry. The information is copied into
|
||||||
the \c stat structure pointed to by \a result.
|
the \c stat structure pointed to by \a result.
|
||||||
|
|
||||||
\b NOTE: The BStatable object does not cache the stat structure; every time you
|
\b NOTE: The BStatable object does not cache the stat structure; every time you
|
||||||
call GetStat(), fresh stat information is retrieved.
|
call GetStat(), fresh stat information is retrieved.
|
||||||
|
|
||||||
\param result pointer to a pre-allocated structure into which the stat information will be copied
|
\param result pointer to a pre-allocated structure into which the stat information will be copied
|
||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
@@ -374,7 +374,7 @@ BEntry::GetStat(struct stat *result) const
|
|||||||
|
|
||||||
/*! \brief Reinitializes the BEntry to the path or directory path combination,
|
/*! \brief Reinitializes the BEntry to the path or directory path combination,
|
||||||
resolving symlinks if traverse is true
|
resolving symlinks if traverse is true
|
||||||
|
|
||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
@@ -429,7 +429,7 @@ BEntry::SetTo(const entry_ref *ref, bool traverse)
|
|||||||
|
|
||||||
/*! \brief Reinitializes the BEntry object to the path, resolving symlinks if
|
/*! \brief Reinitializes the BEntry object to the path, resolving symlinks if
|
||||||
traverse is true
|
traverse is true
|
||||||
|
|
||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
@@ -454,7 +454,7 @@ BEntry::Unset()
|
|||||||
_kern_close(fDirFd);
|
_kern_close(fDirFd);
|
||||||
// BPrivate::Storage::close_dir(fDirFd);
|
// BPrivate::Storage::close_dir(fDirFd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free our leaf name
|
// Free our leaf name
|
||||||
free(fName);
|
free(fName);
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ BEntry::GetRef(entry_ref *ref) const
|
|||||||
|
|
||||||
if (ref == NULL)
|
if (ref == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
status_t error = _kern_read_stat(fDirFd, NULL, false, &st,
|
status_t error = _kern_read_stat(fDirFd, NULL, false, &st,
|
||||||
sizeof(struct stat));
|
sizeof(struct stat));
|
||||||
@@ -499,7 +499,7 @@ BEntry::GetRef(entry_ref *ref) const
|
|||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
|
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BEntry::GetPath(BPath *path) const
|
BEntry::GetPath(BPath *path) const
|
||||||
@@ -518,13 +518,13 @@ BEntry::GetPath(BPath *path) const
|
|||||||
|
|
||||||
If the function fails, the argument is Unset(). Destructive calls to GetParent() are
|
If the function fails, the argument is Unset(). Destructive calls to GetParent() are
|
||||||
allowed, i.e.:
|
allowed, i.e.:
|
||||||
|
|
||||||
\code
|
|
||||||
BEntry entry("/boot/home/fido");
|
|
||||||
status_t err;
|
|
||||||
char name[B_FILE_NAME_LENGTH];
|
|
||||||
|
|
||||||
// Spit out the path components backwards, one at a time.
|
\code
|
||||||
|
BEntry entry("/boot/home/fido");
|
||||||
|
status_t err;
|
||||||
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
|
// Spit out the path components backwards, one at a time.
|
||||||
do {
|
do {
|
||||||
entry.GetName(name);
|
entry.GetName(name);
|
||||||
printf("> %s\n", name);
|
printf("> %s\n", name);
|
||||||
@@ -534,16 +534,16 @@ BEntry::GetPath(BPath *path) const
|
|||||||
if (err != B_ENTRY_NOT_FOUND)
|
if (err != B_ENTRY_NOT_FOUND)
|
||||||
printf(">> Error: %s\n", strerror(err));
|
printf(">> Error: %s\n", strerror(err));
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
will output:
|
will output:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
> fido
|
> fido
|
||||||
> home
|
> home
|
||||||
> boot
|
> boot
|
||||||
> .
|
> .
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\param entry pointer to a pre-allocated BEntry object into which the result is stored
|
\param entry pointer to a pre-allocated BEntry object into which the result is stored
|
||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
@@ -583,10 +583,10 @@ BEntry::GetParent(BEntry *entry) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Gets the parent of the BEntry as a BDirectory.
|
/*! \brief Gets the parent of the BEntry as a BDirectory.
|
||||||
|
|
||||||
If the function fails, the argument is Unset().
|
If the function fails, the argument is Unset().
|
||||||
|
|
||||||
\param dir pointer to a pre-allocated BDirectory object into which the result is stored
|
\param dir pointer to a pre-allocated BDirectory object into which the result is stored
|
||||||
\return
|
\return
|
||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
@@ -635,7 +635,7 @@ status_t
|
|||||||
BEntry::GetName(char *buffer) const
|
BEntry::GetName(char *buffer) const
|
||||||
{
|
{
|
||||||
status_t result = B_ERROR;
|
status_t result = B_ERROR;
|
||||||
|
|
||||||
if (fCStatus != B_OK) {
|
if (fCStatus != B_OK) {
|
||||||
result = B_NO_INIT;
|
result = B_NO_INIT;
|
||||||
} else if (buffer == NULL) {
|
} else if (buffer == NULL) {
|
||||||
@@ -644,7 +644,7 @@ BEntry::GetName(char *buffer) const
|
|||||||
strcpy(buffer, fName);
|
strcpy(buffer, fName);
|
||||||
result = B_OK;
|
result = B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,7 +652,7 @@ BEntry::GetName(char *buffer) const
|
|||||||
/*! \brief Renames the BEntry to path, replacing an existing entry if clobber is true.
|
/*! \brief Renames the BEntry to path, replacing an existing entry if clobber is true.
|
||||||
|
|
||||||
NOTE: The BEntry must refer to an existing file. If it is abstract, this method will fail.
|
NOTE: The BEntry must refer to an existing file. If it is abstract, this method will fail.
|
||||||
|
|
||||||
\param path Pointer to a string containing the new name for the entry. May
|
\param path Pointer to a string containing the new name for the entry. May
|
||||||
be absolute or relative. If relative, the entry is renamed within its
|
be absolute or relative. If relative, the entry is renamed within its
|
||||||
current directory.
|
current directory.
|
||||||
@@ -663,7 +663,7 @@ BEntry::GetName(char *buffer) const
|
|||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
- \c B_ENTRY_EXISTS - The new location is already taken and \c clobber was \c false
|
- \c B_ENTRY_EXISTS - The new location is already taken and \c clobber was \c false
|
||||||
- \c B_ENTRY_NOT_FOUND - Attempted to rename an abstract entry
|
- \c B_ENTRY_NOT_FOUND - Attempted to rename an abstract entry
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
|
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
@@ -695,7 +695,7 @@ BEntry::Rename(const char *path, bool clobber)
|
|||||||
/*! \brief Moves the BEntry to directory or directory+path combination, replacing an existing entry if clobber is true.
|
/*! \brief Moves the BEntry to directory or directory+path combination, replacing an existing entry if clobber is true.
|
||||||
|
|
||||||
NOTE: The BEntry must refer to an existing file. If it is abstract, this method will fail.
|
NOTE: The BEntry must refer to an existing file. If it is abstract, this method will fail.
|
||||||
|
|
||||||
\param dir Pointer to a pre-allocated BDirectory into which the entry should be moved.
|
\param dir Pointer to a pre-allocated BDirectory into which the entry should be moved.
|
||||||
\param path Optional new leaf name for the entry. May be a simple leaf or a relative path;
|
\param path Optional new leaf name for the entry. May be a simple leaf or a relative path;
|
||||||
either way, \c path is reckoned off of \c dir. If \c NULL, the entry retains
|
either way, \c path is reckoned off of \c dir. If \c NULL, the entry retains
|
||||||
@@ -707,7 +707,7 @@ BEntry::Rename(const char *path, bool clobber)
|
|||||||
- \c B_OK - Success
|
- \c B_OK - Success
|
||||||
- \c B_ENTRY_EXISTS - The new location is already taken and \c clobber was \c false
|
- \c B_ENTRY_EXISTS - The new location is already taken and \c clobber was \c false
|
||||||
- \c B_ENTRY_NOT_FOUND - Attempted to move an abstract entry
|
- \c B_ENTRY_NOT_FOUND - Attempted to move an abstract entry
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BEntry::MoveTo(BDirectory *dir, const char *path, bool clobber)
|
BEntry::MoveTo(BDirectory *dir, const char *path, bool clobber)
|
||||||
@@ -737,7 +737,7 @@ BEntry::MoveTo(BDirectory *dir, const char *path, bool clobber)
|
|||||||
the chunk of data they refer to will continue to exist until all such file
|
the chunk of data they refer to will continue to exist until all such file
|
||||||
descriptors are closed. The BEntry object, however, becomes abstract and
|
descriptors are closed. The BEntry object, however, becomes abstract and
|
||||||
no longer refers to any actual data in the filesystem.
|
no longer refers to any actual data in the filesystem.
|
||||||
|
|
||||||
\return
|
\return
|
||||||
- B_OK - Success
|
- B_OK - Success
|
||||||
- "error code" - Failure
|
- "error code" - Failure
|
||||||
@@ -777,7 +777,7 @@ BEntry::operator==(const BEntry &item) const
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +818,7 @@ BEntry::operator=(const BEntry &item)
|
|||||||
if (fCStatus != B_OK)
|
if (fCStatus != B_OK)
|
||||||
Unset();
|
Unset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,7 +853,7 @@ BEntry::set_stat(struct stat &st, uint32 what)
|
|||||||
If \a path is an absolute path, \a dirFD is ignored.
|
If \a path is an absolute path, \a dirFD is ignored.
|
||||||
If \a dirFD is -1, path is considered relative to the current directory
|
If \a dirFD is -1, path is considered relative to the current directory
|
||||||
(unless it is an absolute path, that is).
|
(unless it is an absolute path, that is).
|
||||||
|
|
||||||
The ownership of the file descriptor \a dirFD is transferred to the
|
The ownership of the file descriptor \a dirFD is transferred to the
|
||||||
function, regardless of whether it succeeds or fails. The caller must not
|
function, regardless of whether it succeeds or fails. The caller must not
|
||||||
close the FD afterwards.
|
close the FD afterwards.
|
||||||
@@ -1007,14 +1007,14 @@ status_t
|
|||||||
BEntry::set_name(const char *name)
|
BEntry::set_name(const char *name)
|
||||||
{
|
{
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
free(fName);
|
free(fName);
|
||||||
|
|
||||||
fName = strdup(name);
|
fName = strdup(name);
|
||||||
if (!fName)
|
if (!fName)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,19 +1070,19 @@ BEntry::Dump(const char *name)
|
|||||||
printf("%s\n", name);
|
printf("%s\n", name);
|
||||||
printf("------------------------------------------------------------\n");
|
printf("------------------------------------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("fCStatus == %ld\n", fCStatus);
|
printf("fCStatus == %" B_PRId32 "\n", fCStatus);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (fDirFd != -1
|
if (fDirFd != -1
|
||||||
&& _kern_read_stat(fDirFd, NULL, false, &st,
|
&& _kern_read_stat(fDirFd, NULL, false, &st,
|
||||||
sizeof(struct stat)) == B_OK) {
|
sizeof(struct stat)) == B_OK) {
|
||||||
printf("dir.device == %d\n", (int)st.st_dev);
|
printf("dir.device == %d\n", (int)st.st_dev);
|
||||||
printf("dir.inode == %lld\n", st.st_ino);
|
printf("dir.inode == %" B_PRIdINO "\n", st.st_ino);
|
||||||
} else {
|
} else {
|
||||||
printf("dir == NullFd\n");
|
printf("dir == NullFd\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("leaf == '%s'\n", fName);
|
printf("leaf == '%s'\n", fName);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
@@ -1118,7 +1118,7 @@ get_ref_for_path(const char *path, entry_ref *ref)
|
|||||||
/*! \brief Returns whether an entry is less than another.
|
/*! \brief Returns whether an entry is less than another.
|
||||||
The components are compared in order \c device, \c directory, \c name.
|
The components are compared in order \c device, \c directory, \c name.
|
||||||
A \c NULL \c name is less than any non-null name.
|
A \c NULL \c name is less than any non-null name.
|
||||||
|
|
||||||
\return
|
\return
|
||||||
- true - a < b
|
- true - a < b
|
||||||
- false - a >= b
|
- false - a >= b
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// This software is part of the Haiku distribution and is covered
|
// This software is part of the Haiku distribution and is covered
|
||||||
// by the MIT license.
|
// by the MIT license.
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
/*!
|
/*!
|
||||||
@@ -101,7 +101,7 @@ BNodeInfo::SetTo(BNode *node)
|
|||||||
- \c B_OK: Everything went fine.
|
- \c B_OK: Everything went fine.
|
||||||
- \c B_NO_INIT: The node is not properly initialized.
|
- \c B_NO_INIT: The node is not properly initialized.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::InitCheck() const
|
BNodeInfo::InitCheck() const
|
||||||
{
|
{
|
||||||
return fCStatus;
|
return fCStatus;
|
||||||
@@ -126,7 +126,7 @@ BNodeInfo::InitCheck() const
|
|||||||
- \c B_ENTRY_NOT_FOUND: No type is set on the node.
|
- \c B_ENTRY_NOT_FOUND: No type is set on the node.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::GetType(char *type) const
|
BNodeInfo::GetType(char *type) const
|
||||||
{
|
{
|
||||||
// check parameter and initialization
|
// check parameter and initialization
|
||||||
@@ -255,7 +255,7 @@ BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
|
|||||||
error = fNode->GetAttrInfo(attribute, &attrInfo);
|
error = fNode->GetAttrInfo(attribute, &attrInfo);
|
||||||
if (error == B_OK && attrInfo.type != attrType)
|
if (error == B_OK && attrInfo.type != attrType)
|
||||||
error = B_BAD_TYPE;
|
error = B_BAD_TYPE;
|
||||||
if (error == B_OK && attrInfo.size != attrSize)
|
if (error == B_OK && attrInfo.size != (off_t)attrSize)
|
||||||
error = B_BAD_VALUE; // TODO: B_BAD_DATA?
|
error = B_BAD_VALUE; // TODO: B_BAD_DATA?
|
||||||
// read the attribute
|
// read the attribute
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
@@ -272,7 +272,7 @@ BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
|
|||||||
attrSize);
|
attrSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
read = fNode->ReadAttr(attribute, attrType, 0, icon->Bits(),
|
read = fNode->ReadAttr(attribute, attrType, 0, icon->Bits(),
|
||||||
attrSize);
|
attrSize);
|
||||||
}
|
}
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
@@ -312,7 +312,7 @@ BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
|
|||||||
and icon size (\a k) do not match.
|
and icon size (\a k) do not match.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
@@ -393,7 +393,7 @@ BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
|||||||
- \c B_BAD_VALUE: \c NULL \a signature or bad app_verb \a verb.
|
- \c B_BAD_VALUE: \c NULL \a signature or bad app_verb \a verb.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::GetPreferredApp(char *signature, app_verb verb) const
|
BNodeInfo::GetPreferredApp(char *signature, app_verb verb) const
|
||||||
{
|
{
|
||||||
// check parameter and initialization
|
// check parameter and initialization
|
||||||
@@ -442,7 +442,7 @@ BNodeInfo::GetPreferredApp(char *signature, app_verb verb) const
|
|||||||
\c B_MIME_TYPE_LENGTH or bad app_verb \a verb.
|
\c B_MIME_TYPE_LENGTH or bad app_verb \a verb.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::SetPreferredApp(const char *signature, app_verb verb)
|
BNodeInfo::SetPreferredApp(const char *signature, app_verb verb)
|
||||||
{
|
{
|
||||||
// check parameters and initialization
|
// check parameters and initialization
|
||||||
@@ -483,7 +483,7 @@ BNodeInfo::SetPreferredApp(const char *signature, app_verb verb)
|
|||||||
- \c B_BAD_VALUE: \c NULL \a ref.
|
- \c B_BAD_VALUE: \c NULL \a ref.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::GetAppHint(entry_ref *ref) const
|
BNodeInfo::GetAppHint(entry_ref *ref) const
|
||||||
{
|
{
|
||||||
// check parameter and initialization
|
// check parameter and initialization
|
||||||
@@ -535,7 +535,7 @@ BNodeInfo::GetAppHint(entry_ref *ref) const
|
|||||||
- \c B_BAD_VALUE: \c NULL \a ref.
|
- \c B_BAD_VALUE: \c NULL \a ref.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::SetAppHint(const entry_ref *ref)
|
BNodeInfo::SetAppHint(const entry_ref *ref)
|
||||||
{
|
{
|
||||||
// check parameter and initialization
|
// check parameter and initialization
|
||||||
@@ -593,7 +593,7 @@ BNodeInfo::SetAppHint(const entry_ref *ref)
|
|||||||
dimensions (\a icon) and icon size (\a iconSize) do not match.
|
dimensions (\a icon) and icon size (\a iconSize) do not match.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||||
{
|
{
|
||||||
// set some icon size related variables
|
// set some icon size related variables
|
||||||
@@ -717,7 +717,7 @@ error = B_ENTRY_NOT_FOUND;
|
|||||||
bitmap dimensions (\a icon) and icon size (\a iconSize) do not match.
|
bitmap dimensions (\a icon) and icon size (\a iconSize) do not match.
|
||||||
- other error codes
|
- other error codes
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BNodeInfo::GetTrackerIcon(const entry_ref *ref, BBitmap *icon, icon_size iconSize)
|
BNodeInfo::GetTrackerIcon(const entry_ref *ref, BBitmap *icon, icon_size iconSize)
|
||||||
{
|
{
|
||||||
// check ref param
|
// check ref param
|
||||||
@@ -736,17 +736,17 @@ BNodeInfo::GetTrackerIcon(const entry_ref *ref, BBitmap *icon, icon_size iconSiz
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BNodeInfo::_ReservedNodeInfo1()
|
BNodeInfo::_ReservedNodeInfo1()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BNodeInfo::_ReservedNodeInfo2()
|
BNodeInfo::_ReservedNodeInfo2()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BNodeInfo::_ReservedNodeInfo3()
|
BNodeInfo::_ReservedNodeInfo3()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ BPositionIO::Read(void *buffer, size_t size)
|
|||||||
ssize_t result = ReadAt(curPos, buffer, size);
|
ssize_t result = ReadAt(curPos, buffer, size);
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
Seek(result, SEEK_CUR);
|
Seek(result, SEEK_CUR);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ BPositionIO::Write(const void *buffer, size_t size)
|
|||||||
ssize_t result = WriteAt(curPos, buffer, size);
|
ssize_t result = WriteAt(curPos, buffer, size);
|
||||||
if (result > 0)
|
if (result > 0)
|
||||||
Seek(result, SEEK_CUR);
|
Seek(result, SEEK_CUR);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ BMemoryIO::BMemoryIO(void *p, size_t len)
|
|||||||
fLen(len),
|
fLen(len),
|
||||||
fPhys(len),
|
fPhys(len),
|
||||||
fPos(0)
|
fPos(0)
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,10 +185,10 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
if (buffer == NULL || pos < 0)
|
if (buffer == NULL || pos < 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos < fLen) {
|
if (pos < (off_t)fLen) {
|
||||||
sizeRead = min_c(static_cast<off_t>(size), fLen - pos);
|
sizeRead = min_c((off_t)size, (off_t)fLen - pos);
|
||||||
memcpy(buffer, fBuf + pos, sizeRead);
|
memcpy(buffer, fBuf + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
@@ -198,22 +198,22 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
// WriteAt
|
// WriteAt
|
||||||
ssize_t
|
ssize_t
|
||||||
BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
if (buffer == NULL || pos < 0)
|
if (buffer == NULL || pos < 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeWritten = 0;
|
ssize_t sizeWritten = 0;
|
||||||
if (pos < fPhys) {
|
if (pos < (off_t)fPhys) {
|
||||||
sizeWritten = min_c(static_cast<off_t>(size), fPhys - pos);
|
sizeWritten = min_c((off_t)size, (off_t)fPhys - pos);
|
||||||
memcpy(fBuf + pos, buffer, sizeWritten);
|
memcpy(fBuf + pos, buffer, sizeWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos + sizeWritten > fLen)
|
if (pos + sizeWritten > (off_t)fLen)
|
||||||
fLen = pos + sizeWritten;
|
fLen = pos + sizeWritten;
|
||||||
|
|
||||||
return sizeWritten;
|
return sizeWritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,13 +228,13 @@ BMemoryIO::Seek(off_t position, uint32 seek_mode)
|
|||||||
break;
|
break;
|
||||||
case SEEK_CUR:
|
case SEEK_CUR:
|
||||||
fPos += position;
|
fPos += position;
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
fPos = fLen + position;
|
fPos = fLen + position;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return fPos;
|
return fPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,11 +252,11 @@ status_t
|
|||||||
BMemoryIO::SetSize(off_t size)
|
BMemoryIO::SetSize(off_t size)
|
||||||
{
|
{
|
||||||
status_t err = B_ERROR;
|
status_t err = B_ERROR;
|
||||||
|
|
||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
if (size <= fPhys) {
|
if (size <= (off_t)fPhys) {
|
||||||
err = B_OK;
|
err = B_OK;
|
||||||
fLen = size;
|
fLen = size;
|
||||||
}
|
}
|
||||||
@@ -311,10 +311,10 @@ BMallocIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos < fLength) {
|
if (pos < (off_t)fLength) {
|
||||||
sizeRead = min_c(static_cast<off_t>(size), fLength - pos);
|
sizeRead = min_c((off_t)size, (off_t)fLength - pos);
|
||||||
memcpy(buffer, fData + pos, sizeRead);
|
memcpy(buffer, fData + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
@@ -327,14 +327,14 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
size_t newSize = max_c(pos + size, static_cast<off_t>(fLength));
|
size_t newSize = max_c(pos + (off_t)size, (off_t)fLength);
|
||||||
|
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
|
|
||||||
if (newSize > fMallocSize)
|
if (newSize > fMallocSize)
|
||||||
error = SetSize(newSize);
|
error = SetSize(newSize);
|
||||||
|
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
memcpy(fData + pos, buffer, size);
|
memcpy(fData + pos, buffer, size);
|
||||||
if (pos + size > fLength)
|
if (pos + size > fLength)
|
||||||
@@ -386,22 +386,22 @@ BMallocIO::SetSize(off_t size)
|
|||||||
} else {
|
} else {
|
||||||
// size != 0, see, if necessary to resize
|
// size != 0, see, if necessary to resize
|
||||||
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
||||||
if (size != fMallocSize) {
|
if (size != (off_t)fMallocSize) {
|
||||||
// we need to resize
|
// we need to resize
|
||||||
if (char *newData = static_cast<char*>(realloc(fData, newSize))) {
|
if (char *newData = static_cast<char*>(realloc(fData, newSize))) {
|
||||||
// set the new area to 0
|
// set the new area to 0
|
||||||
if (newSize > fMallocSize)
|
if (newSize > fMallocSize)
|
||||||
memset(newData + fMallocSize, 0, newSize - fMallocSize);
|
memset(newData + fMallocSize, 0, newSize - fMallocSize);
|
||||||
fData = newData;
|
fData = newData;
|
||||||
fMallocSize = newSize;
|
fMallocSize = newSize;
|
||||||
} else // couldn't alloc the memory
|
} else // couldn't alloc the memory
|
||||||
error = B_NO_MEMORY;
|
error = B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error == B_OK)
|
if (error == B_OK)
|
||||||
fLength = size;
|
fLength = size;
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user