diff --git a/headers/private/storage/mime/DatabaseLocation.h b/headers/private/storage/mime/DatabaseLocation.h
index 22769cb..69b3424 100644
a
|
b
|
public:
|
38 | 38 | // opening type nodes |
39 | 39 | |
40 | 40 | 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; |
44 | 44 | |
45 | 45 | // generic type attributes access |
46 | 46 | |
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)
|
126 | 126 | else { |
127 | 127 | bool didCreate = false; |
128 | 128 | BNode node; |
129 | | err = fLocation->OpenOrCreateType(type, node, &didCreate); |
| 129 | err = fLocation->OpenWritableType(type, node, true, &didCreate); |
130 | 130 | if (!err && didCreate) { |
131 | 131 | fInstalledTypes.AddType(type); |
132 | 132 | _SendInstallNotification(type); |
… |
… |
Database::SetIconForType(const char *type, const char *fileType,
|
443 | 443 | BNode node; |
444 | 444 | bool didCreate = false; |
445 | 445 | |
446 | | status_t err = fLocation->OpenOrCreateType(type, node, &didCreate); |
| 446 | status_t err = fLocation->OpenWritableType(type, node, true, &didCreate); |
447 | 447 | if (err != B_OK) |
448 | 448 | return err; |
449 | 449 | |
… |
… |
Database::SetIconForType(const char *type, const char *fileType,
|
504 | 504 | BNode node; |
505 | 505 | bool didCreate = false; |
506 | 506 | |
507 | | status_t err = fLocation->OpenOrCreateType(type, node, &didCreate); |
| 507 | status_t err = fLocation->OpenWritableType(type, node, true, &didCreate); |
508 | 508 | if (err != B_OK) |
509 | 509 | return err; |
510 | 510 | |
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
|
69 | 69 | |
70 | 70 | |
71 | 71 | /*! \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). |
73 | 73 | All MIME types are converted to lowercase for use in the filesystem. |
74 | 74 | \param type The MIME type to open. |
75 | 75 | \param _node Node opened on the given MIME type. |
76 | 76 | \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 |
78 | 78 | otherwise. |
79 | 79 | */ |
80 | 80 | status_t |
81 | | DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node, |
| 81 | DatabaseLocation::OpenWritableType(const char* type, BNode& _node, bool create, |
82 | 82 | bool* _didCreate) const |
83 | 83 | { |
84 | 84 | if (_didCreate) |
… |
… |
DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
|
90 | 90 | if (error == B_OK) { |
91 | 91 | if (index == 0) |
92 | 92 | return B_OK; |
| 93 | else if (!create) |
| 94 | return B_ENTRY_NOT_FOUND; |
93 | 95 | |
94 | 96 | // The caller wants a editable node, but the node found is not in the |
95 | 97 | // user's settings directory. Copy the node. |
… |
… |
DatabaseLocation::OpenOrCreateType(const char* type, BNode& _node,
|
106 | 108 | if (_didCreate != NULL) |
107 | 109 | *_didCreate = true; |
108 | 110 | return error; |
109 | | } |
| 111 | } else if (!create) |
| 112 | return B_ENTRY_NOT_FOUND; |
110 | 113 | |
111 | 114 | // type doesn't exist yet -- create the respective node |
112 | 115 | error = _CreateTypeNode(type, _node); |
… |
… |
DatabaseLocation::WriteAttribute(const char* type, const char* attribute,
|
256 | 259 | return B_BAD_VALUE; |
257 | 260 | |
258 | 261 | BNode node; |
259 | | status_t error = OpenOrCreateType(type, node, _didCreate); |
| 262 | status_t error = OpenWritableType(type, node, true, _didCreate); |
260 | 263 | if (error != B_OK) |
261 | 264 | return error; |
262 | 265 | |
… |
… |
DatabaseLocation::DeleteAttribute(const char* type, const char* attribute) const
|
312 | 315 | return B_BAD_VALUE; |
313 | 316 | |
314 | 317 | BNode node; |
315 | | int32 index; |
316 | | status_t error = _OpenType(type, node, index); |
| 318 | status_t error = OpenWritableType(type, node, false); |
317 | 319 | if (error != B_OK) |
318 | 320 | return error; |
319 | 321 | |
320 | | if (index != 0) |
321 | | return B_NOT_ALLOWED; |
322 | | |
323 | 322 | return node.RemoveAttr(attribute); |
324 | 323 | } |
325 | 324 | |
… |
… |
DatabaseLocation::DeleteAttribute(const char* type, const char* attribute) const
|
327 | 326 | /*! \brief Fetches the application hint for the given MIME type. |
328 | 327 | |
329 | 328 | The entry_ref pointed to by \c ref must be pre-allocated. |
330 | | |
| 329 | |
331 | 330 | \param type The MIME type of interest |
332 | 331 | \param _ref Reference to a pre-allocated \c entry_ref struct into |
333 | 332 | which the location of the hint application is copied. |
… |
… |
DatabaseLocation::GetShortDescription(const char* type, char* description)
|
418 | 417 | /*! The string pointed to by \c description must be long enough to |
419 | 418 | hold the long description; a length of \c B_MIME_TYPE_LENGTH is |
420 | 419 | recommended. |
421 | | |
| 420 | |
422 | 421 | \param type The MIME type of interest |
423 | 422 | \param description Pointer to a pre-allocated string into which the long |
424 | 423 | description is copied. If the function fails, the contents of the string |
… |
… |
DatabaseLocation::GetFileExtensions(const char* type, BMessage& _extensions)
|
465 | 464 | _extensions.what = 234; // Don't know why, but that's what R5 does. |
466 | 465 | err = _extensions.AddString("type", type); |
467 | 466 | } |
468 | | return err; |
| 467 | return err; |
469 | 468 | } |
470 | 469 | |
471 | 470 | |
… |
… |
DatabaseLocation::GetIcon(const char* type, uint8*& _data, size_t& _size)
|
524 | 523 | \return |
525 | 524 | - \c B_OK: Success |
526 | 525 | - \c B_ENTRY_NOT_FOUND: No icon of the given size exists for the given type |
527 | | - "error code": Failure |
| 526 | - "error code": Failure |
528 | 527 | |
529 | 528 | */ |
530 | 529 | status_t |
… |
… |
DatabaseLocation::GetIconForType(const char* type, const char* fileType,
|
562 | 561 | largeIconAttrName, which, &_icon); |
563 | 562 | |
564 | 563 | // ssize_t err = type && icon ? B_OK : B_BAD_VALUE; |
565 | | // |
| 564 | // |
566 | 565 | // // Figure out what kind of data we *should* find |
567 | 566 | // uint32 attrType = 0; |
568 | 567 | // ssize_t attrSize = 0; |
… |
… |
DatabaseLocation::GetIconForType(const char* type, const char* fileType,
|
586 | 585 | // } |
587 | 586 | // } |
588 | 587 | // // Construct our attribute name |
589 | | // std::string attr; |
| 588 | // std::string attr; |
590 | 589 | // if (fileType) { |
591 | 590 | // attr = (which == B_MINI_ICON |
592 | 591 | // ? kMiniIconAttrPrefix |
… |
… |
DatabaseLocation::GetIconForType(const char* type, const char* fileType,
|
602 | 601 | // } |
603 | 602 | // |
604 | 603 | // BNode node; |
605 | | // if (!err) |
| 604 | // if (!err) |
606 | 605 | // err = open_type(type, &node); |
607 | 606 | // |
608 | 607 | // attr_info info; |
609 | | // if (!err) |
| 608 | // if (!err) |
610 | 609 | // err = node.GetAttrInfo(attr.c_str(), &info); |
611 | 610 | // |
612 | 611 | // if (!err) |
… |
… |
DatabaseLocation::GetIconForType(const char* type, const char* fileType,
|
620 | 619 | // buffer = new(std::nothrow) char[attrSize]; |
621 | 620 | // if (!buffer) |
622 | 621 | // 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); |
625 | 624 | // } else { |
626 | 625 | // // same color space, just read direct |
627 | 626 | // err = node.ReadAttr(attr.c_str(), attrType, 0, icon->Bits(), attrSize); |
… |
… |
DatabaseLocation::GetSupportedTypes(const char* type, BMessage& _types)
|
775 | 774 | err = B_OK; |
776 | 775 | } |
777 | 776 | if (err == B_OK) { |
778 | | _types.what = 0; |
| 777 | _types.what = 0; |
779 | 778 | err = _types.AddString("type", type); |
780 | 779 | } |
781 | 780 | return err; |
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)
|
131 | 131 | BAppFileInfo appFileInfoWrite; |
132 | 132 | if (!err && updateAppInfo && node.IsFile() |
133 | 133 | && 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) { |
137 | 137 | |
138 | 138 | // we read from resources and write to attributes |
139 | 139 | appFileInfoRead.SetInfoLocation(B_USE_RESOURCES); |