Style clean-ups *and* Index::Update() now correctly converts B_MIME_STRING_TYPE
to B_STRING_TYPE for the lower layers - should probably find a better solution to handle this. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2166 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,6 +14,12 @@
|
|||||||
|
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
|
|
||||||
|
// B_MIME_STRING_TYPE is defined in storage/Mime.h, but we
|
||||||
|
// don't need the whole file here; the type can't change anyway
|
||||||
|
#ifndef _MIME_H
|
||||||
|
# define B_MIME_STRING_TYPE 'MIMS'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Index::Index(Volume *volume)
|
Index::Index(Volume *volume)
|
||||||
:
|
:
|
||||||
@@ -190,7 +196,8 @@ Index::Create(Transaction *transaction,const char *name,uint32 type)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Index::Update(Transaction *transaction,const char *name,int32 type,const uint8 *oldKey,uint16 oldLength,const uint8 *newKey,uint16 newLength,Inode *inode)
|
Index::Update(Transaction *transaction, const char *name, int32 type, const uint8 *oldKey,
|
||||||
|
uint16 oldLength, const uint8 *newKey, uint16 newLength, Inode *inode)
|
||||||
{
|
{
|
||||||
if (name == NULL
|
if (name == NULL
|
||||||
|| oldKey == NULL && newKey == NULL
|
|| oldKey == NULL && newKey == NULL
|
||||||
@@ -198,6 +205,10 @@ Index::Update(Transaction *transaction,const char *name,int32 type,const uint8 *
|
|||||||
|| newKey != NULL && newLength == 0)
|
|| newKey != NULL && newLength == 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
// B_MIME_STRING_TYPE is the only supported non-standard type
|
||||||
|
if (type == B_MIME_STRING_TYPE)
|
||||||
|
type = B_STRING_TYPE;
|
||||||
|
|
||||||
// if the two keys are identical, don't do anything
|
// if the two keys are identical, don't do anything
|
||||||
if (type != 0 && !compareKeys(type, oldKey, oldLength, newKey, newLength))
|
if (type != 0 && !compareKeys(type, oldKey, oldLength, newKey, newLength))
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -228,7 +239,7 @@ Index::Update(Transaction *transaction,const char *name,int32 type,const uint8 *
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the new key to the key
|
// add the new key to the tree
|
||||||
|
|
||||||
if (newKey != NULL)
|
if (newKey != NULL)
|
||||||
status = tree->Insert(transaction, (const uint8 *)newKey, newLength, inode->ID());
|
status = tree->Insert(transaction, (const uint8 *)newKey, newLength, inode->ID());
|
||||||
@@ -256,7 +267,8 @@ Index::UpdateName(Transaction *transaction,const char *oldName, const char *newN
|
|||||||
{
|
{
|
||||||
uint16 oldLength = oldName ? strlen(oldName) : 0;
|
uint16 oldLength = oldName ? strlen(oldName) : 0;
|
||||||
uint16 newLength = newName ? strlen(newName) : 0;
|
uint16 newLength = newName ? strlen(newName) : 0;
|
||||||
return Update(transaction,"name",B_STRING_TYPE,(uint8 *)oldName,oldLength,(uint8 *)newName,newLength,inode);
|
return Update(transaction, "name", B_STRING_TYPE, (uint8 *)oldName, oldLength,
|
||||||
|
(uint8 *)newName, newLength, inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -282,9 +294,9 @@ Index::UpdateSize(Transaction *transaction, Inode *inode)
|
|||||||
{
|
{
|
||||||
off_t oldSize = inode->OldSize();
|
off_t oldSize = inode->OldSize();
|
||||||
off_t newSize = inode->Size();
|
off_t newSize = inode->Size();
|
||||||
status_t status = Update(transaction,"size",B_INT64_TYPE,(uint8 *)&oldSize,sizeof(int64),
|
|
||||||
(uint8 *)&newSize,sizeof(int64),inode);
|
|
||||||
|
|
||||||
|
status_t status = Update(transaction, "size", B_INT64_TYPE, (uint8 *)&oldSize,
|
||||||
|
sizeof(int64), (uint8 *)&newSize, sizeof(int64), inode);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
inode->UpdateOldSize();
|
inode->UpdateOldSize();
|
||||||
|
|
||||||
@@ -296,7 +308,8 @@ status_t
|
|||||||
Index::InsertLastModified(Transaction *transaction, Inode *inode)
|
Index::InsertLastModified(Transaction *transaction, Inode *inode)
|
||||||
{
|
{
|
||||||
off_t modified = inode->LastModified();
|
off_t modified = inode->LastModified();
|
||||||
return Update(transaction,"last_modified",B_INT64_TYPE,NULL,0,(uint8 *)&modified,sizeof(int64),inode);
|
return Update(transaction, "last_modified", B_INT64_TYPE, NULL, 0,
|
||||||
|
(uint8 *)&modified, sizeof(int64), inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -305,7 +318,8 @@ Index::RemoveLastModified(Transaction *transaction, Inode *inode)
|
|||||||
{
|
{
|
||||||
// Inode::OldLastModified() is the value which is in the index
|
// Inode::OldLastModified() is the value which is in the index
|
||||||
off_t modified = inode->OldLastModified();
|
off_t modified = inode->OldLastModified();
|
||||||
return Update(transaction,"last_modified",B_INT64_TYPE,(uint8 *)&modified,sizeof(int64),NULL,0,inode);
|
return Update(transaction, "last_modified", B_INT64_TYPE, (uint8 *)&modified,
|
||||||
|
sizeof(int64), NULL, 0, inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -317,8 +331,8 @@ Index::UpdateLastModified(Transaction *transaction, Inode *inode, off_t modified
|
|||||||
modified = (bigtime_t)time(NULL) << INODE_TIME_SHIFT;
|
modified = (bigtime_t)time(NULL) << INODE_TIME_SHIFT;
|
||||||
modified |= fVolume->GetUniqueID() & INODE_TIME_MASK;
|
modified |= fVolume->GetUniqueID() & INODE_TIME_MASK;
|
||||||
|
|
||||||
status_t status = Update(transaction,"last_modified",B_INT64_TYPE,(uint8 *)&oldModified,sizeof(int64),
|
status_t status = Update(transaction, "last_modified", B_INT64_TYPE, (uint8 *)&oldModified,
|
||||||
(uint8 *)&modified,sizeof(int64),inode);
|
sizeof(int64), (uint8 *)&modified, sizeof(int64), inode);
|
||||||
|
|
||||||
inode->Node()->last_modified_time = modified;
|
inode->Node()->last_modified_time = modified;
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user