[haiku-development] Path.cpp.diff && ResourcesContainer.cpp.diff
- From: kaoutsis <kaoutsis@xxxxxx>
- To: haiku-development <haiku-development@xxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 15:44:45 +0300
Hi there,
Followed Stephan's and Andreas' suggestions, thanks;
reworked the two patches:
* using 'svn log' in order to extract the authors' list and the
initial chronology of the two source files.
Good bye,
Vasilis
Index: src/build/libbe/storage/Path.cpp
===================================================================
--- src/build/libbe/storage/Path.cpp (revision 25700)
+++ src/build/libbe/storage/Path.cpp (working copy)
@@ -1,12 +1,21 @@
-//----------------------------------------------------------------------
-// This software is part of the OpenBeOS distribution and is covered
-// by the OpenBeOS license.
-//---------------------------------------------------------------------
+/*
+ * Copyright 2002-2008, Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Tyler Dauwalder, tyler@xxxxxxxxxxxxx
+ * Bill Hayden, haydentech@xxxxxxxxxxxxxxxxxxxxx
+ * Erik Jakowatz
+ * Ingo Weinhold, ingo_weinhold@xxxxxx
+ */
+
+
/*!
\file Path.cpp
BPath implementation.
*/
+
#include <new>
#include <Path.h>
@@ -25,45 +34,54 @@
using namespace OpenBeOS;
#endif
+
//! Creates an uninitialized BPath object.
BPath::BPath()
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
}
+
-//! Creates a copy of the given BPath object.
-/*! \param path the object to be copied
+/*! Creates a copy of the given BPath object.
+ \param path the object to be copied
*/
BPath::BPath(const BPath &path)
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
*this = path;
}
+
/*! \brief Creates a BPath object and initializes it to the filesystem entry
specified by the given entry_ref struct.
\param ref the entry_ref
*/
BPath::BPath(const entry_ref *ref)
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
SetTo(ref);
}
+
/*! Creates a BPath object and initializes it to the filesystem entry
specified by the given BEntry object.
\param entry the BEntry object
*/
BPath::BPath(const BEntry *entry)
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
SetTo(entry);
}
+
/*! \brief Creates a BPath object and initializes it to the specified path or
path and filename combination.
\param dir The base component of the pathname. May be absolute or
relative.
@@ -75,12 +93,14 @@
may occur even if false (see \ref MustNormalize).
*/
BPath::BPath(const char *dir, const char *leaf, bool normalize)
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
SetTo(dir, leaf, normalize);
}
-
+
+
/*! \brief Creates a BPath object and initializes it to the specified directory
and filename combination.
\param dir Refers to the directory that provides the base component of
the
@@ -92,20 +112,23 @@
may occur even if false (see \ref MustNormalize).
*/
BPath::BPath(const BDirectory *dir, const char *leaf, bool normalize)
- : fName(NULL),
- fCStatus(B_NO_INIT)
+ :
+ fName(NULL),
+ fCStatus(B_NO_INIT)
{
SetTo(dir, leaf, normalize);
}
+
//! Destroys the BPath object and frees any of its associated resources.
BPath::~BPath()
{
Unset();
}
-//! Returns the status of the most recent construction or SetTo() call.
-/*! \return \c B_OK, if the BPath object is properly initialized, an error
+
+/*! Returns the status of the most recent construction or SetTo() call.
+ \return \c B_OK, if the BPath object is properly initialized, an error
code otherwise.
*/
status_t
@@ -114,6 +137,7 @@
return fCStatus;
}
+
/*! \brief Reinitializes the object to the filesystem entry specified by the
given entry_ref struct.
\param ref the entry_ref
@@ -139,6 +163,7 @@
return fCStatus;
}
+
/*! \brief Reinitializes the object to the specified filesystem entry.
\param entry the BEntry
\return
@@ -160,6 +185,7 @@
fCStatus = error;
return error;
}
+
/*! \brief Reinitializes the object to the specified path or path and file
name combination.
@@ -232,7 +258,8 @@
fCStatus = error;
return error;
}
-
+
+
/*! \brief Reinitializes the object to the specified directory and relative
path combination.
\param dir Refers to the directory that provides the base component of
the
@@ -265,6 +292,7 @@
fCStatus = error;
return error;
}
+
/*! \brief Returns the object to an uninitialized state. The object frees
any
resources it allocated and marks itself as uninitialized.
@@ -275,6 +303,7 @@
set_path(NULL);
fCStatus = B_NO_INIT;
}
+
/*! \brief Appends the given (relative) path to the end of the current path.
This call fails if the path is absolute or the object to which you're
@@ -299,26 +328,28 @@
fCStatus = error;
return error;
}
+
-//! Returns the object's complete path name.
-/*! \return
+/*! Returns the object's complete path name.
+ \return
- the object's path name, or
- \c NULL, if it is not properly initialized.
*/
-const char *
+const char*
BPath::Path() const
{
return fName;
}
-
-//! Returns the leaf portion of the object's path name.
-/*! The leaf portion is defined as the string after the last \c '/'. For
+
+
+/*! Returns the leaf portion of the object's path name.
+ The leaf portion is defined as the string after the last \c '/'. For
the root path (\c "/") it is the empty string (\c "").
\return
- the leaf portion of the object's path name, or
- \c NULL, if it is not properly initialized.
*/
-const char *
+const char*
BPath::Leaf() const
{
const char *result = NULL;
@@ -334,6 +365,7 @@
return result;
}
+
/*! \brief Calls the argument's SetTo() method with the name of the
object's parent directory.
No normalization is done.
@@ -369,9 +401,10 @@
}
return error;
}
+
-//! Performs a simple (string-wise) comparison of paths.
-/*! No normalization takes place! Uninitialized BPath objects are considered
+/*! Performs a simple (string-wise) comparison of paths.
+ No normalization takes place! Uninitialized BPath objects are considered
to be equal.
\param item the BPath object to be compared with
\return \c true, if the path names are equal, \c false otherwise.
@@ -382,20 +415,22 @@
return (*this == item.Path());
}
-//! Performs a simple (string-wise) comparison of paths.
-/*! No normalization takes place!
+
+/*! Performs a simple (string-wise) comparison of paths.
+ No normalization takes place!
\param path the path name to be compared with
\return \c true, if the path names are equal, \c false otherwise.
*/
bool
BPath::operator==(const char *path) const
{
- return (InitCheck() != B_OK && path == NULL
- || fName && path && strcmp(fName, path) == 0);
+ return ((InitCheck() != B_OK && (path == NULL))
+ || ((fName && path) && strcmp(fName, path)) == 0);
}
-//! Performs a simple (string-wise) comparison of paths.
-/*! No normalization takes place! Uninitialized BPath objects are considered
+
+/*! Performs a simple (string-wise) comparison of paths.
+ No normalization takes place! Uninitialized BPath objects are considered
to be equal.
\param item the BPath object to be compared with
\return \c true, if the path names are not equal, \c false otherwise.
@@ -406,8 +441,9 @@
return !(*this == item);
}
-//! Performs a simple (string-wise) comparison of paths.
-/*! No normalization takes place!
+
+/*! Performs a simple (string-wise) comparison of paths.
+ No normalization takes place!
\param path the path name to be compared with
\return \c true, if the path names are not equal, \c false otherwise.
*/
@@ -416,9 +452,10 @@
{
return !(*this == path);
}
-
-//! Initializes the object to be a copy of the argument.
-/*! \param item the BPath object to be copied
+
+
+/*! Initializes the object to be a copy of the argument.
+ \param item the BPath object to be copied
\return \c *this
*/
BPath&
@@ -429,8 +466,9 @@
return *this;
}
-//! Initializes the object to be a copy of the argument.
-/*! Has the same effect as \code SetTo(path) \endcode.
+
+/*! Initializes the object to be a copy of the argument.
+ Has the same effect as \code SetTo(path) \endcode.
\param path the path name to be assigned to this object
\return \c *this
*/
@@ -459,8 +497,8 @@
= sizeof(dev_t) + sizeof(ino_t);
-//! Returns \c false.
-/*! Implements BFlattenable.
+/*! Returns \c false.
+ Implements BFlattenable.
\return \c false
*/
bool
@@ -468,9 +506,10 @@
{
return false;
}
-
-//! Returns \c B_REF_TYPE.
-/*! Implements BFlattenable.
+
+
+/*! Returns \c B_REF_TYPE.
+ Implements BFlattenable.
\return \c B_REF_TYPE
*/
type_code
@@ -478,6 +517,7 @@
{
return B_REF_TYPE;
}
+
/*! \brief Returns the size of the flattened entry_ref structure that
represents the pathname.
@@ -497,6 +537,7 @@
}
return size;
}
+
/*! \brief Converts the object's pathname to an entry_ref and writes it into
buffer.
@@ -535,9 +576,10 @@
}
return error;
}
-
-//! Returns \c true if code is \c B_REF_TYPE, and false otherwise.
-/*! Implements BFlattenable.
+
+
+/*! Returns \c true if code is \c B_REF_TYPE, and false otherwise.
+ Implements BFlattenable.
\param code the type code in question
\return \c true if code is \c B_REF_TYPE, and false otherwise.
*/
@@ -546,6 +588,7 @@
{
return (code == B_REF_TYPE);
}
+
/*! \brief Initializes the BPath with the flattened entry_ref data that's
found in the supplied buffer.
@@ -586,10 +629,12 @@
return error;
}
+
void BPath::_WarPath1() {}
void BPath::_WarPath2() {}
void BPath::_WarPath3() {}
+
/*! \brief Sets the supplied path.
The path is copied. If \c NULL, the object's path is set to NULL as
well.
The object's old path is deleted.
@@ -618,7 +663,6 @@
}
-
/*! \brief Checks a path to see if normalization is required.
The following items require normalization:
@@ -719,6 +763,3 @@
\var status_t BPath::fCStatus
\brief The object's initialization status.
*/
-
-
-
Index: src/build/libbe/storage/ResourcesContainer.cpp
===================================================================
--- src/build/libbe/storage/ResourcesContainer.cpp (revision 25700)
+++ src/build/libbe/storage/ResourcesContainer.cpp (working copy)
@@ -1,40 +1,47 @@
-//----------------------------------------------------------------------
-// This software is part of the OpenBeOS distribution and is covered
-// by the OpenBeOS license.
-//---------------------------------------------------------------------
+/*
+ * Copyright 2002-2008, Haiku Inc. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Tyler Dauwalder, tyler@xxxxxxxxxxxxx
+ * Erik Jakowatz
+ * Ingo Weinhold, ingo_weinhold@xxxxxx
+ */
+
+
/*!
\file ResourcesContainer.cpp
ResourcesContainer implementation.
*/
+
#include <stdio.h>
#include "ResourcesContainer.h"
-
#include "ResourceItem.h"
+
namespace BPrivate {
namespace Storage {
-// constructor
+
ResourcesContainer::ResourcesContainer()
- : fResources(),
- fIsModified(false)
+ :
+ fResources(),
+ fIsModified(false)
{
}
-// destructor
+
ResourcesContainer::~ResourcesContainer()
{
MakeEmpty();
}
-// AddResource
-//
-// Returns false, if item is NULL or memory is insufficient, true otherwise.
+
+//! Returns false, if item is NULL or memory is insufficient, true otherwise.
bool
-ResourcesContainer::AddResource(ResourceItem *item, int32 index,
- bool replace)
+ResourcesContainer::AddResource(ResourceItem *item, int32 index, bool replace)
{
bool result = false;
if (item) {
@@ -50,7 +57,7 @@
return result;
}
-// RemoveResource
+
ResourceItem*
ResourcesContainer::RemoveResource(int32 index)
{
@@ -60,14 +67,14 @@
return item;
}
-// RemoveResource
+
bool
ResourcesContainer::RemoveResource(ResourceItem *item)
{
return RemoveResource(IndexOf(item));
}
-// MakeEmpty
+
void
ResourcesContainer::MakeEmpty()
{
@@ -77,7 +84,7 @@
SetModified(false);
}
-// AssimilateResources
+
void
ResourcesContainer::AssimilateResources(ResourcesContainer &container)
{
@@ -98,14 +105,14 @@
SetModified(true);
}
-// IndexOf
+
int32
ResourcesContainer::IndexOf(ResourceItem *item) const
{
return fResources.IndexOf(item);
}
-// IndexOf
+
int32
ResourcesContainer::IndexOf(const void *data) const
{
@@ -120,7 +127,7 @@
return index;
}
-// IndexOf
+
int32
ResourcesContainer::IndexOf(type_code type, int32 id) const
{
@@ -134,7 +141,7 @@
return index;
}
-// IndexOf
+
int32
ResourcesContainer::IndexOf(type_code type, const char *name) const
{
@@ -143,16 +150,17 @@
for (int32 i = 0; index == -1 && i < count; i++) {
ResourceItem *item = ResourceAt(i);
const char *itemName = item->Name();
- if (item->Type() == type && (name == NULL && itemName == NULL
- ||
name != NULL && itemName != NULL
-
&& !strcmp(name, itemName))) {
+ if (item->Type() == type
+ && (((name == NULL && itemName == NULL)
+ || (name != NULL && itemName != NULL))
+ && !strcmp(name, itemName))) {
index = i;
}
}
return index;
}
-// IndexOfType
+
int32
ResourcesContainer::IndexOfType(type_code type, int32 typeIndex) const
{
@@ -169,21 +177,21 @@
return index;
}
-// ResourceAt
+
ResourceItem*
ResourcesContainer::ResourceAt(int32 index) const
{
return (ResourceItem*)fResources.ItemAt(index);
}
-// CountResources
+
int32
ResourcesContainer::CountResources() const
{
return fResources.CountItems();
}
-// SetModified
+
void
ResourcesContainer::SetModified(bool modified)
{
@@ -196,7 +204,7 @@
}
}
-// IsModified
+
bool
ResourcesContainer::IsModified() const
{
@@ -210,7 +218,3 @@
}; // namespace Storage
}; // namespace BPrivate
-
-
-
-
- Follow-Ups:
- [haiku-development] Re: Path.cpp.diff && ResourcesContainer.cpp.diff
- From: Stephan Assmus
Other related posts:
- » [haiku-development] Path.cpp.diff && ResourcesContainer.cpp.diff
- » [haiku-development] Re: Path.cpp.diff && ResourcesContainer.cpp.diff
- [haiku-development] Re: Path.cpp.diff && ResourcesContainer.cpp.diff
- From: Stephan Assmus