Ticket #10435: 10435.patch

File 10435.patch, 7.8 KB (added by anevilyak, 10 years ago)
  • headers/private/storage/mime/DatabaseLocation.h

    diff --git a/headers/private/storage/mime/DatabaseLocation.h b/headers/private/storage/mime/DatabaseLocation.h
    index 22769cb..69b3424 100644
    a b public:  
    3838            // opening type nodes
    3939
    4040            status_t            OpenType(const char* type, BNode& _node) const;
    41             status_t            OpenOrCreateType(const char* type,
    42                                     BNode& _node, bool* _didCreate = NULL)
    43                                     const;
     41            status_t            OpenWritableType(const char* type,
     42                                    BNode& _node, bool create,
     43                                    bool* _didCreate = NULL) const;
    4444
    4545            // generic type attributes access
    4646
  • src/kits/storage/mime/Database.cpp

    diff --git a/src/kits/storage/mime/Database.cpp b/src/kits/storage/mime/Database.cpp
    index d9841a1..d99d33e 100644
    a b Database::Install(const char *type)  
    126126        else {
    127127            bool didCreate = false;
    128128            BNode node;
    129             err = fLocation->OpenOrCreateType(type, node, &didCreate);
     129            err = fLocation->OpenWritableType(type, node, true, &didCreate);
    130130            if (!err && didCreate) {
    131131                fInstalledTypes.AddType(type);
    132132                _SendInstallNotification(type);
    Database::SetIconForType(const char *type, const char *fileType,  
    443443    BNode node;
    444444    bool didCreate = false;
    445445
    446     status_t err = fLocation->OpenOrCreateType(type, node, &didCreate);
     446    status_t err = fLocation->OpenWritableType(type, node, true, &didCreate);
    447447    if (err != B_OK)
    448448        return err;
    449449
    Database::SetIconForType(const char *type, const char *fileType,  
    504504    BNode node;
    505505    bool didCreate = false;
    506506
    507     status_t err = fLocation->OpenOrCreateType(type, node, &didCreate);
     507    status_t err = fLocation->OpenWritableType(type, node, true, &didCreate);
    508508    if (err != B_OK)
    509509        return err;
    510510
  • src/kits/storage/mime/DatabaseLocation.cpp

    diff --git a/src/kits/storage/mime/DatabaseLocation.cpp b/src/kits/storage/mime/DatabaseLocation.cpp
    index bbe3642..5bb1a9c 100644
    a b DatabaseLocation::OpenType(const char* type, BNode& _node) const  
    6969
    7070
    7171/*! \brief Opens a BNode on the given type, creating a node of the
    72         appropriate flavor if necessary.
     72        appropriate flavor if requested (and necessary).
    7373    All MIME types are converted to lowercase for use in the filesystem.
    7474    \param type The MIME type to open.
    7575    \param _node Node opened on the given MIME type.
    7676    \param _didCreate If not \c NULL, the variable the pointer refers to is
    77         set to \c true, if the node has been newly create, to \c false
     77        set to \c true, if the node has been newly created, to \c false
    7878        otherwise.
    7979*/
    8080status_t
    81 DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
     81DatabaseLocation::OpenWritableType(const char* type, BNode& _node, bool create,
    8282    bool* _didCreate) const
    8383{
    8484    if (_didCreate)
    DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,  
    9090    if (error == B_OK) {
    9191        if (index == 0)
    9292            return B_OK;
     93        else if (!create)
     94            return B_ENTRY_NOT_FOUND;
    9395
    9496        // The caller wants a editable node, but the node found is not in the
    9597        // user's settings directory. Copy the node.
    DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,  
    106108        if (_didCreate != NULL)
    107109            *_didCreate = true;
    108110        return error;
    109     }
     111    } else if (!create)
     112        return B_ENTRY_NOT_FOUND;
    110113
    111114    // type doesn't exist yet -- create the respective node
    112115    error = _CreateTypeNode(type, _node);
    DatabaseLocation::WriteAttribute(const char* type, const char* attribute,  
    256259        return B_BAD_VALUE;
    257260
    258261    BNode node;
    259     status_t error = OpenOrCreateType(type, node, _didCreate);
     262    status_t error = OpenWritableType(type, node, true, _didCreate);
    260263    if (error != B_OK)
    261264        return error;
    262265
    DatabaseLocation::DeleteAttribute(const char* type, const char* attribute) const  
    312315        return B_BAD_VALUE;
    313316
    314317    BNode node;
    315     int32 index;
    316     status_t error = _OpenType(type, node, index);
     318    status_t error = OpenWritableType(type, node, false);
    317319    if (error != B_OK)
    318320        return error;
    319321
    320     if (index != 0)
    321         return B_NOT_ALLOWED;
    322 
    323322    return node.RemoveAttr(attribute);
    324323}
    325324
    DatabaseLocation::DeleteAttribute(const char* type, const char* attribute) const  
    327326/*! \brief Fetches the application hint for the given MIME type.
    328327
    329328    The entry_ref pointed to by \c ref must be pre-allocated.
    330 
     329
    331330    \param type The MIME type of interest
    332331    \param _ref Reference to a pre-allocated \c entry_ref struct into
    333332               which the location of the hint application is copied.
    DatabaseLocation::GetShortDescription(const char* type, char* description)  
    418417/*! The string pointed to by \c description must be long enough to
    419418    hold the long description; a length of \c B_MIME_TYPE_LENGTH is
    420419    recommended.
    421 
     420
    422421    \param type The MIME type of interest
    423422    \param description Pointer to a pre-allocated string into which the long
    424423        description is copied. If the function fails, the contents of the string
    DatabaseLocation::GetFileExtensions(const char* type, BMessage& _extensions)  
    465464        _extensions.what = 234; // Don't know why, but that's what R5 does.
    466465        err = _extensions.AddString("type", type);
    467466    }
    468     return err;
     467    return err;
    469468}
    470469
    471470
    DatabaseLocation::GetIcon(const char* type, uint8*& _data, size_t& _size)  
    524523    \return
    525524    - \c B_OK: Success
    526525    - \c B_ENTRY_NOT_FOUND: No icon of the given size exists for the given type
    527     - "error code": Failure
     526    - "error code": Failure
    528527
    529528*/
    530529status_t
    DatabaseLocation::GetIconForType(const char* type, const char* fileType,  
    562561        largeIconAttrName, which, &_icon);
    563562
    564563//  ssize_t err = type && icon ? B_OK : B_BAD_VALUE;
    565 //
     564//
    566565//  // Figure out what kind of data we *should* find
    567566//  uint32 attrType = 0;
    568567//  ssize_t attrSize = 0;
    DatabaseLocation::GetIconForType(const char* type, const char* fileType,  
    586585//      }
    587586//  }
    588587//  // Construct our attribute name
    589 //  std::string attr;
     588//  std::string attr;
    590589//  if (fileType) {
    591590//      attr = (which == B_MINI_ICON
    592591//                ? kMiniIconAttrPrefix
    DatabaseLocation::GetIconForType(const char* type, const char* fileType,  
    602601//  }
    603602//
    604603//  BNode node;
    605 //  if (!err)
     604//  if (!err)
    606605//      err = open_type(type, &node);
    607606//
    608607//  attr_info info;
    609 //  if (!err)
     608//  if (!err)
    610609//      err = node.GetAttrInfo(attr.c_str(), &info);
    611610//
    612611//  if (!err)
    DatabaseLocation::GetIconForType(const char* type, const char* fileType,  
    620619//          buffer = new(std::nothrow) char[attrSize];
    621620//          if (!buffer)
    622621//              err = B_NO_MEMORY;
    623 //          if (!err)
    624 //              err = node.ReadAttr(attr.c_str(), attrType, 0, buffer, attrSize);
     622//          if (!err)
     623//              err = node.ReadAttr(attr.c_str(), attrType, 0, buffer, attrSize);
    625624//      } else {
    626625//          // same color space, just read direct
    627626//          err = node.ReadAttr(attr.c_str(), attrType, 0, icon->Bits(), attrSize);
    DatabaseLocation::GetSupportedTypes(const char* type, BMessage& _types)  
    775774        err = B_OK;
    776775    }
    777776    if (err == B_OK) {
    778         _types.what = 0;
     777        _types.what = 0;
    779778        err = _types.AddString("type", type);
    780779    }
    781780    return err;
  • src/kits/storage/mime/MimeInfoUpdater.cpp

    diff --git a/src/kits/storage/mime/MimeInfoUpdater.cpp b/src/kits/storage/mime/MimeInfoUpdater.cpp
    index 5e878cd..c921917 100644
    a b MimeInfoUpdater::Do(const entry_ref& entry, bool* _entryIsDir)  
    131131    BAppFileInfo appFileInfoWrite;
    132132    if (!err && updateAppInfo && node.IsFile()
    133133        && is_shared_object_mime_type(type)
    134         && file.SetTo(&entry, B_READ_WRITE) == B_OK
    135         && appFileInfoRead.SetTo(&file) == B_OK
    136         && appFileInfoWrite.SetTo(&file) == B_OK) {
     134        && (err = file.SetTo(&entry, B_READ_WRITE)) == B_OK
     135        && (err = appFileInfoRead.SetTo(&file)) == B_OK
     136        && (err = appFileInfoWrite.SetTo(&file)) == B_OK) {
    137137
    138138        // we read from resources and write to attributes
    139139        appFileInfoRead.SetInfoLocation(B_USE_RESOURCES);