Dealt with the *_LENGTH+1 issue: Removed all "+1"s in buffer allocations and adjusted checks etc.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1131 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
893d12fc2c
commit
9a17c3cfac
@ -146,11 +146,11 @@ status_t
|
||||
BDirectory::SetTo(const entry_ref *ref)
|
||||
{
|
||||
Unset();
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
error = BPrivate::Storage::entry_ref_to_path(ref, path,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
}
|
||||
if (error == B_OK)
|
||||
error = SetTo(path);
|
||||
@ -488,16 +488,16 @@ BDirectory::Contains(const BEntry *entry, int32 nodeFlags) const
|
||||
// If the directory is initialized, get the canonical paths of the dir and
|
||||
// the entry and check, if the latter is a prefix of the first one.
|
||||
if (result && InitCheck() == B_OK) {
|
||||
char dirPath[B_PATH_NAME_LENGTH + 1];
|
||||
char entryPath[B_PATH_NAME_LENGTH + 1];
|
||||
char dirPath[B_PATH_NAME_LENGTH];
|
||||
char entryPath[B_PATH_NAME_LENGTH];
|
||||
result = (BPrivate::Storage::dir_to_path(fDirFd, dirPath,
|
||||
B_PATH_NAME_LENGTH + 1) == B_OK);
|
||||
B_PATH_NAME_LENGTH) == B_OK);
|
||||
entry_ref ref;
|
||||
if (result)
|
||||
result = (entry->GetRef(&ref) == B_OK);
|
||||
if (result) {
|
||||
result = (BPrivate::Storage::entry_ref_to_path(&ref, entryPath,
|
||||
B_PATH_NAME_LENGTH + 1)
|
||||
B_PATH_NAME_LENGTH)
|
||||
== B_OK);
|
||||
}
|
||||
if (result)
|
||||
|
@ -377,15 +377,15 @@ BEntry::SetTo(const BDirectory *dir, const char *path, bool traverse)
|
||||
if (dir->InitCheck() != B_OK)
|
||||
fCStatus = B_BAD_VALUE;
|
||||
// get the dir's path
|
||||
char rootPath[B_PATH_NAME_LENGTH + 1];
|
||||
char rootPath[B_PATH_NAME_LENGTH];
|
||||
if (fCStatus == B_OK) {
|
||||
fCStatus = BPrivate::Storage::dir_to_path(dir->get_fd(), rootPath,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
}
|
||||
// Concatenate our two path strings together
|
||||
if (fCStatus == B_OK && path) {
|
||||
// The concatenated strings must fit into our buffer.
|
||||
if (strlen(rootPath) + strlen(path) + 2 > B_PATH_NAME_LENGTH + 1)
|
||||
if (strlen(rootPath) + strlen(path) + 2 > B_PATH_NAME_LENGTH)
|
||||
fCStatus = B_NAME_TOO_LONG;
|
||||
else {
|
||||
strcat(rootPath, "/");
|
||||
@ -416,10 +416,10 @@ BEntry::SetTo(const entry_ref *ref, bool traverse)
|
||||
return (fCStatus = B_BAD_VALUE);
|
||||
}
|
||||
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
|
||||
fCStatus = BPrivate::Storage::entry_ref_to_path(ref, path,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
return (fCStatus == B_OK) ? SetTo(path, traverse) : fCStatus ;
|
||||
}
|
||||
|
||||
@ -656,7 +656,7 @@ BEntry::GetParent(BDirectory *dir) const
|
||||
/*! \brief Gets the name of the entry's leaf.
|
||||
|
||||
\c buffer must be pre-allocated and of sufficient
|
||||
length to hold the entire string. A length of \c B_FILE_NAME_LENGTH+1 is recommended.
|
||||
length to hold the entire string. A length of \c B_FILE_NAME_LENGTH is recommended.
|
||||
|
||||
\param buffer pointer to a pre-allocated string into which the result is copied
|
||||
\return
|
||||
@ -708,11 +708,11 @@ BEntry::Rename(const char *path, bool clobber)
|
||||
|
||||
status_t status = B_OK;
|
||||
// Convert the given path to an absolute path, if it isn't already.
|
||||
char fullPath[B_PATH_NAME_LENGTH + 1];
|
||||
char fullPath[B_PATH_NAME_LENGTH];
|
||||
if (!BPrivate::Storage::is_absolute_path(path)) {
|
||||
// Convert our directory to an absolute pathname
|
||||
status = BPrivate::Storage::dir_to_path(fDirFd, fullPath,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
if (status == B_OK) {
|
||||
// Concatenate our pathname to it
|
||||
strcat(fullPath, "/");
|
||||
@ -781,9 +781,9 @@ BEntry::MoveTo(BDirectory *dir, const char *path = NULL, bool clobber)
|
||||
// Determine the absolute path of the target entry.
|
||||
if (!BPrivate::Storage::is_absolute_path(path)) {
|
||||
// Convert our directory to an absolute pathname
|
||||
char fullPath[B_PATH_NAME_LENGTH + 1];
|
||||
char fullPath[B_PATH_NAME_LENGTH];
|
||||
status = BPrivate::Storage::dir_to_path(dir->get_fd(), fullPath,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
// Concatenate our pathname to it
|
||||
if (status == B_OK) {
|
||||
strcat(fullPath, "/");
|
||||
@ -965,7 +965,7 @@ BEntry::set(BPrivate::Storage::FileDescriptor dirFd, const char *leaf, bool trav
|
||||
// convert the dir FD into a BPath
|
||||
entry_ref ref;
|
||||
error = BPrivate::Storage::dir_to_self_entry_ref(dirFd, &ref);
|
||||
char dirPathname[B_PATH_NAME_LENGTH + 1];
|
||||
char dirPathname[B_PATH_NAME_LENGTH];
|
||||
if (error == B_OK) {
|
||||
error = BPrivate::Storage::entry_ref_to_path(&ref, dirPathname,
|
||||
sizeof(dirPathname));
|
||||
|
@ -150,11 +150,11 @@ status_t
|
||||
BFile::SetTo(const entry_ref *ref, uint32 openMode)
|
||||
{
|
||||
Unset();
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
error = BPrivate::Storage::entry_ref_to_path(ref, path,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
}
|
||||
if (error == B_OK)
|
||||
error = SetTo(path, openMode);
|
||||
|
@ -222,7 +222,7 @@ BMimeType::GetSupertype(BMimeType *superType) const
|
||||
if (i == len)
|
||||
err = B_BAD_VALUE; // IsSupertypeOnly() == true
|
||||
else {
|
||||
char superMime[B_MIME_TYPE_LENGTH+1];
|
||||
char superMime[B_MIME_TYPE_LENGTH];
|
||||
strncpy(superMime, fType, i);
|
||||
superMime[i] = 0;
|
||||
err = superType->SetTo(superMime);
|
||||
@ -241,8 +241,8 @@ BMimeType::GetSupertype(BMimeType *superType) const
|
||||
bool
|
||||
BMimeType::operator==(const BMimeType &type) const
|
||||
{
|
||||
char lower1[B_MIME_TYPE_LENGTH+1];
|
||||
char lower2[B_MIME_TYPE_LENGTH+1];
|
||||
char lower1[B_MIME_TYPE_LENGTH];
|
||||
char lower2[B_MIME_TYPE_LENGTH];
|
||||
|
||||
if (InitCheck() == B_OK && type.InitCheck() == B_OK) {
|
||||
status_t err = toLower(Type(), lower1);
|
||||
@ -399,7 +399,7 @@ BMimeType::GetIcon(BBitmap *icon, icon_size size) const
|
||||
that's associated with the file's type.
|
||||
|
||||
The string pointed to by \c signature must be long enough to
|
||||
hold the preferred applications signature; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the preferred applications signature; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
\param signature Pointer to a pre-allocated string into which the signature of the preferred app is copied. If
|
||||
@ -519,7 +519,7 @@ BMimeType::GetFileExtensions(BMessage *extensions) const
|
||||
// GetShortDescription
|
||||
//! Fetches the MIME type's short description from the MIME database
|
||||
/*! The string pointed to by \c description must be long enough to
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
\param description Pointer to a pre-allocated string into which the long description is copied. If
|
||||
@ -541,7 +541,7 @@ BMimeType::GetShortDescription(char *description) const
|
||||
// GetLongDescription
|
||||
//! Fetches the MIME type's long description from the MIME database
|
||||
/*! The string pointed to by \c description must be long enough to
|
||||
hold the long description; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the long description; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
\param description Pointer to a pre-allocated string into which the long description is copied. If
|
||||
@ -672,7 +672,7 @@ BMimeType::SetIcon(const BBitmap *icon, icon_size which)
|
||||
that's associated with the file's type.
|
||||
|
||||
The string pointed to by \c signature must be of
|
||||
length less than or equal to \c B_MIME_TYPE_LENGTH characters.
|
||||
length less than \c B_MIME_TYPE_LENGTH characters.
|
||||
|
||||
\note If the MIME type is not installed, it will first be installed, and then
|
||||
the preferred app will be set.
|
||||
@ -849,7 +849,7 @@ BMimeType::SetFileExtensions(const BMessage *extensions)
|
||||
// SetShortDescription
|
||||
//! Sets the short description field for the MIME type
|
||||
/*! The string pointed to by \c description must be of
|
||||
length less than or equal to \c B_MIME_TYPE_LENGTH characters.
|
||||
length less than \c B_MIME_TYPE_LENGTH characters.
|
||||
|
||||
\note If the MIME type is not installed, it will first be installed, and then
|
||||
the short description will be set.
|
||||
@ -891,7 +891,7 @@ BMimeType::SetShortDescription(const char *description)
|
||||
// SetLongDescription
|
||||
//! Sets the long description field for the MIME type
|
||||
/*! The string pointed to by \c description must be of
|
||||
length less than or equal to \c B_MIME_TYPE_LENGTH characters.
|
||||
length less than \c B_MIME_TYPE_LENGTH characters.
|
||||
|
||||
\note If the MIME type is not installed, it will first be installed, and then
|
||||
the long description will be set.
|
||||
@ -1064,7 +1064,7 @@ BMimeType::IsValid(const char *string)
|
||||
|
||||
bool foundSlash = false;
|
||||
int len = strlen(string);
|
||||
if (len > B_MIME_TYPE_LENGTH || len == 0)
|
||||
if (len >= B_MIME_TYPE_LENGTH || len == 0)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
@ -196,11 +196,11 @@ status_t
|
||||
BNode::SetTo(const entry_ref *ref)
|
||||
{
|
||||
Unset();
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
error = BPrivate::Storage::entry_ref_to_path(ref, path,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
B_PATH_NAME_LENGTH);
|
||||
}
|
||||
if (error == B_OK)
|
||||
error = SetTo(path);
|
||||
@ -475,7 +475,7 @@ status_t
|
||||
BNode::GetNextAttrName(char *buffer)
|
||||
{
|
||||
// We're allowed to assume buffer is at least
|
||||
// B_BUFFER_NAME_LENGTH chars long, but NULLs
|
||||
// B_ATTR_NAME_LENGTH chars long, but NULLs
|
||||
// are not acceptable.
|
||||
if (buffer == NULL)
|
||||
return B_BAD_VALUE; // /new R5 crashed when passed NULL
|
||||
|
@ -125,7 +125,7 @@ BPath::SetTo(const entry_ref *ref)
|
||||
Unset();
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
error = BPrivate::Storage::entry_ref_to_path(ref, path, sizeof(path));
|
||||
if (error == B_OK)
|
||||
error = set_path(path); // the path is already normalized
|
||||
@ -175,7 +175,7 @@ BPath::SetTo(const char *path, const char *leaf, bool normalize)
|
||||
status_t error = (path ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && leaf && BPrivate::Storage::is_absolute_path(leaf))
|
||||
error = B_BAD_VALUE;
|
||||
char newPath[B_PATH_NAME_LENGTH + 1];
|
||||
char newPath[B_PATH_NAME_LENGTH];
|
||||
if (error == B_OK) {
|
||||
// we always normalize relative paths
|
||||
normalize |= !BPrivate::Storage::is_absolute_path(path);
|
||||
@ -212,7 +212,7 @@ BPath::SetTo(const char *path, const char *leaf, bool normalize)
|
||||
// normalize the path, if necessary, otherwise just set it
|
||||
if (error == B_OK) {
|
||||
if (normalize) {
|
||||
char normalizedPath[B_PATH_NAME_LENGTH + 1];
|
||||
char normalizedPath[B_PATH_NAME_LENGTH];
|
||||
error = BPrivate::Storage::get_canonical_path(newPath, normalizedPath,
|
||||
sizeof(normalizedPath));
|
||||
if (error == B_OK)
|
||||
@ -351,7 +351,7 @@ BPath::GetParent(BPath *path) const
|
||||
if (len == 1) // handle "/"
|
||||
error = B_ENTRY_NOT_FOUND;
|
||||
else {
|
||||
char parentPath[B_PATH_NAME_LENGTH + 1];
|
||||
char parentPath[B_PATH_NAME_LENGTH];
|
||||
len--;
|
||||
while (fName[len] != '/' && len > 0)
|
||||
len--;
|
||||
|
@ -137,7 +137,7 @@ BResourceStrings::SetStringFile(const entry_ref *ref)
|
||||
fileRef = *ref;
|
||||
fFileRef = *ref;
|
||||
} else {
|
||||
char appPath[B_PATH_NAME_LENGTH + 1];
|
||||
char appPath[B_PATH_NAME_LENGTH];
|
||||
error = BPrivate::Storage::get_app_path(appPath);
|
||||
if (error == B_OK)
|
||||
error = get_ref_for_path(appPath, &fileRef);
|
||||
|
@ -205,7 +205,7 @@ BSymLink::ReadLink(char *buf, size_t size)
|
||||
entry_ref ref;
|
||||
if (error == B_OK)
|
||||
error = fSecretEntry->GetRef(&ref);
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
if (error == B_OK)
|
||||
error = BPrivate::Storage::entry_ref_to_path(&ref, path, sizeof(path));
|
||||
if (error == B_OK)
|
||||
@ -259,7 +259,7 @@ ssize_t
|
||||
BSymLink::MakeLinkedPath(const BDirectory *dir, BPath *path)
|
||||
{
|
||||
ssize_t result = (dir && path ? 0 : B_BAD_VALUE);
|
||||
char contents[B_PATH_NAME_LENGTH + 1];
|
||||
char contents[B_PATH_NAME_LENGTH];
|
||||
if (result == 0)
|
||||
result = ReadLink(contents, sizeof(contents));
|
||||
if (result >= 0) {
|
||||
@ -283,7 +283,7 @@ BSymLink::MakeLinkedPath(const BDirectory *dir, BPath *path)
|
||||
bool
|
||||
BSymLink::IsAbsolute()
|
||||
{
|
||||
char contents[B_PATH_NAME_LENGTH + 1];
|
||||
char contents[B_PATH_NAME_LENGTH];
|
||||
bool result = (ReadLink(contents, sizeof(contents)) >= 0);
|
||||
if (result)
|
||||
result = BPrivate::Storage::is_absolute_path(contents);
|
||||
|
@ -342,10 +342,10 @@ BPrivate::Storage::get_stat(FileDescriptor file, Stat *s)
|
||||
status_t
|
||||
BPrivate::Storage::get_stat(entry_ref &ref, Stat *result)
|
||||
{
|
||||
char path[B_PATH_NAME_LENGTH + 1];
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
status_t status;
|
||||
|
||||
status = BPrivate::Storage::entry_ref_to_path(&ref, path, B_PATH_NAME_LENGTH + 1);
|
||||
status = BPrivate::Storage::entry_ref_to_path(&ref, path, B_PATH_NAME_LENGTH);
|
||||
return (status != B_OK) ? status : BPrivate::Storage::get_stat(path, result);
|
||||
}
|
||||
|
||||
@ -1045,11 +1045,11 @@ BPrivate::Storage::get_canonical_path(const char *path, char *&result)
|
||||
{
|
||||
status_t error = (path ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
result = new(nothrow) char[B_PATH_NAME_LENGTH + 1];
|
||||
result = new(nothrow) char[B_PATH_NAME_LENGTH];
|
||||
if (!result)
|
||||
error = B_NO_MEMORY;
|
||||
if (error == B_OK) {
|
||||
error = get_canonical_path(path, result, B_PATH_NAME_LENGTH + 1);
|
||||
error = get_canonical_path(path, result, B_PATH_NAME_LENGTH);
|
||||
if (error != B_OK) {
|
||||
delete[] result;
|
||||
result = NULL;
|
||||
@ -1090,12 +1090,11 @@ BPrivate::Storage::get_canonical_dir_path(const char *path, char *&result)
|
||||
{
|
||||
status_t error = (path ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
result = new(nothrow) char[B_PATH_NAME_LENGTH + 1];
|
||||
result = new(nothrow) char[B_PATH_NAME_LENGTH];
|
||||
if (!result)
|
||||
error = B_NO_MEMORY;
|
||||
if (error == B_OK) {
|
||||
error = get_canonical_dir_path(path, result,
|
||||
B_PATH_NAME_LENGTH + 1);
|
||||
error = get_canonical_dir_path(path, result, B_PATH_NAME_LENGTH);
|
||||
if (error != B_OK) {
|
||||
delete[] result;
|
||||
result = NULL;
|
||||
|
@ -162,7 +162,7 @@ InstalledTypes::AddType(const char *type)
|
||||
err = AddSupertype(type, i);
|
||||
} else {
|
||||
// Copy the supertype
|
||||
char super[B_PATH_NAME_LENGTH+1];
|
||||
char super[B_PATH_NAME_LENGTH];
|
||||
strncpy(super, type, i);
|
||||
super[i] = 0;
|
||||
|
||||
@ -205,7 +205,7 @@ InstalledTypes::RemoveType(const char *type)
|
||||
err = RemoveSupertype(type);
|
||||
} else {
|
||||
// Copy the supertype
|
||||
char super[B_PATH_NAME_LENGTH+1];
|
||||
char super[B_PATH_NAME_LENGTH];
|
||||
strncpy(super, type, i);
|
||||
super[i] = 0;
|
||||
|
||||
@ -287,7 +287,7 @@ InstalledTypes::AddSubtype(Supertype &super, const char *sub)
|
||||
if (!err)
|
||||
err = super.AddSubtype(sub);
|
||||
if (!err && fCachedMessage) {
|
||||
char type[B_PATH_NAME_LENGTH+1];
|
||||
char type[B_PATH_NAME_LENGTH];
|
||||
sprintf(type, "%s/%s", super.GetName(), sub);
|
||||
err = fCachedMessage->AddString("types", type);
|
||||
}
|
||||
@ -383,7 +383,7 @@ InstalledTypes::BuildInstalledTypesList()
|
||||
break;
|
||||
} else {
|
||||
// Check that this entry is both a directory and a valid MIME string
|
||||
char supertype[B_PATH_NAME_LENGTH+1];
|
||||
char supertype[B_PATH_NAME_LENGTH];
|
||||
if (entry.IsDirectory()
|
||||
&& entry.GetName(supertype) == B_OK
|
||||
&& BMimeType::IsValid(supertype))
|
||||
@ -413,7 +413,7 @@ InstalledTypes::BuildInstalledTypesList()
|
||||
break;
|
||||
} else {
|
||||
// Get the subtype's name
|
||||
char subtype[B_PATH_NAME_LENGTH+1];
|
||||
char subtype[B_PATH_NAME_LENGTH];
|
||||
if (subEntry.GetName(subtype) == B_OK) {
|
||||
BPrivate::Storage::to_lower(subtype);
|
||||
|
||||
|
@ -78,7 +78,7 @@ Supertype::AddSubtype(const char *sub)
|
||||
if (!err)
|
||||
err = fSubtypes.insert(sub).second ? B_OK : B_NAME_IN_USE;
|
||||
if (!err && fCachedMessage) {
|
||||
char type[B_PATH_NAME_LENGTH+1];
|
||||
char type[B_PATH_NAME_LENGTH];
|
||||
sprintf(type, "%s/%s", fName.c_str(), sub);
|
||||
err = fCachedMessage->AddString("types", type);
|
||||
}
|
||||
@ -132,7 +132,7 @@ Supertype::FillMessageWithTypes(BMessage &msg) const
|
||||
status_t err = B_OK;
|
||||
std::set<std::string>::const_iterator i;
|
||||
for (i = fSubtypes.begin(); i != fSubtypes.end() && !err; i++) {
|
||||
char type[B_PATH_NAME_LENGTH+1];
|
||||
char type[B_PATH_NAME_LENGTH];
|
||||
sprintf(type, "%s/%s", fName.c_str(), (*i).c_str());
|
||||
err = msg.AddString(kTypesField, type);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ SupportingApps::BuildSupportingAppsTable()
|
||||
} else {
|
||||
BPath path;
|
||||
BMessage msg;
|
||||
char appSig[B_PATH_NAME_LENGTH+1];
|
||||
char appSig[B_PATH_NAME_LENGTH];
|
||||
err = path.SetTo(&ref);
|
||||
if (!err) {
|
||||
// Construct a mime type string
|
||||
|
@ -51,7 +51,7 @@ namespace Mime {
|
||||
status_t
|
||||
get_app_hint(const char *type, entry_ref *ref)
|
||||
{
|
||||
char path[B_MIME_TYPE_LENGTH+1];
|
||||
char path[B_MIME_TYPE_LENGTH];
|
||||
BEntry entry;
|
||||
ssize_t err = ref ? B_OK : B_BAD_VALUE;
|
||||
if (!err)
|
||||
@ -92,7 +92,7 @@ get_attr_info(const char *type, BMessage *info)
|
||||
// get_short_description
|
||||
//! Fetches the short description for the given MIME type.
|
||||
/*! The string pointed to by \c description must be long enough to
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
\param type The MIME type of interest
|
||||
@ -116,7 +116,7 @@ get_short_description(const char *type, char *description)
|
||||
// get_long_description
|
||||
//! Fetches the long description for the given MIME type.
|
||||
/*! The string pointed to by \c description must be long enough to
|
||||
hold the long description; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the long description; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
\param type The MIME type of interest
|
||||
@ -283,7 +283,7 @@ get_icon_for_type(const char *type, const char *fileType, BBitmap *icon,
|
||||
// get_preferred_app
|
||||
//! Fetches signature of the MIME type's preferred application for the given action.
|
||||
/*! The string pointed to by \c signature must be long enough to
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH+1 is
|
||||
hold the short description; a length of \c B_MIME_TYPE_LENGTH is
|
||||
recommended.
|
||||
|
||||
Currently, the only supported app verb is \c B_OPEN.
|
||||
|
@ -251,14 +251,6 @@ parse_first_path_component(const char *path, char *&component,
|
||||
- \c B_BAD_VALUE, if \a entry is \c NULL or contains a "/",
|
||||
- \c B_NAME_TOO_LONG, if \a entry is too long
|
||||
\note \c "" is considered a valid entry name.
|
||||
\note According to a couple of tests the deal is the following:
|
||||
The length of an entry name must not exceed \c B_FILE_NAME_LENGTH
|
||||
including the terminating null character, whereas the null character
|
||||
is not included in the \c B_PATH_NAME_LENGTH characters for a path
|
||||
name.
|
||||
Therefore the sufficient buffer sizes for entry/path names are
|
||||
\c B_FILE_NAME_LENGTH and \c B_PATH_NAME_LENGTH + 1 respectively.
|
||||
However, I recommend to use "+ 1" in both cases.
|
||||
*/
|
||||
status_t
|
||||
check_entry_name(const char *entry)
|
||||
@ -278,7 +270,7 @@ check_entry_name(const char *entry)
|
||||
}
|
||||
|
||||
/*! An path name is considered valid, if its length doesn't exceed
|
||||
\c B_PATH_NAME_LENGTH (NOT including the terminating null) and each of
|
||||
\c B_PATH_NAME_LENGTH (including the terminating null) and each of
|
||||
its components is a valid entry name.
|
||||
\param entry the entry name
|
||||
\return
|
||||
@ -286,14 +278,6 @@ check_entry_name(const char *entry)
|
||||
- \c B_BAD_VALUE, if \a path is \c NULL,
|
||||
- \c B_NAME_TOO_LONG, if \a path, or any of its components is too long
|
||||
\note \c "" is considered a valid path name.
|
||||
\note According to a couple of tests the deal is the following:
|
||||
The length of an entry name must not exceed \c B_FILE_NAME_LENGTH
|
||||
including the terminating null character, whereas the null character
|
||||
is not included in the \c B_PATH_NAME_LENGTH characters for a path
|
||||
name.
|
||||
Therefore the sufficient buffer sizes for entry/path names are
|
||||
\c B_FILE_NAME_LENGTH and \c B_PATH_NAME_LENGTH + 1 respectively.
|
||||
However, I recommend to use "+ 1" in both cases.
|
||||
*/
|
||||
status_t
|
||||
check_path_name(const char *path)
|
||||
@ -311,7 +295,7 @@ check_path_name(const char *path)
|
||||
}
|
||||
} while (error == B_OK && nextComponent != 0);
|
||||
// check the length of the path
|
||||
if (error == B_OK && strlen(path) > B_PATH_NAME_LENGTH)
|
||||
if (error == B_OK && strlen(path) >= B_PATH_NAME_LENGTH)
|
||||
error = B_NAME_TOO_LONG;
|
||||
return error;
|
||||
}
|
||||
@ -333,7 +317,7 @@ to_lower(const char *str, std::string &result)
|
||||
{
|
||||
if (str) {
|
||||
result = "";
|
||||
for (int i = 0; i < strlen(str); i++)
|
||||
for (int i = 0; i < (int)strlen(str); i++)
|
||||
result += tolower(str[i]);
|
||||
} else
|
||||
result = "(null)";
|
||||
@ -347,7 +331,7 @@ to_lower(const char *str, char *result)
|
||||
{
|
||||
if (str && result) {
|
||||
int i;
|
||||
for (i = 0; i < strlen(str); i++)
|
||||
for (i = 0; i < (int)strlen(str); i++)
|
||||
result[i] = tolower(str[i]);
|
||||
result[i] = 0;
|
||||
}
|
||||
@ -363,5 +347,3 @@ to_lower(char *str)
|
||||
}; // namespace Storage
|
||||
}; // namespace BPrivate
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user