Ticket #5827: FSUtils.patch

File FSUtils.patch, 2.4 KB (added by anevilyak, 14 years ago)
  • src/kits/tracker/FSUtils.cpp

     
    23562356status_t
    23572357FSGetTrashDir(BDirectory *trashDir, dev_t dev)
    23582358{
    2359 
    23602359    BVolume volume(dev);
    23612360    status_t result = volume.InitCheck();
    23622361    if (result != B_OK)
     
    23712370    if (result != B_OK)
    23722371        return result;
    23732372
     2373    // make trash invisible
     2374    StatStruct sbuf;
     2375    trashDir->GetStat(&sbuf);
     2376
     2377    PoseInfo poseInfo;
     2378    poseInfo.fInvisible = true;
     2379    poseInfo.fInitedDirectory = sbuf.st_ino;
     2380    trashDir->WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
     2381        sizeof(PoseInfo));
     2382
     2383    size_t size;
     2384    const void* data = GetTrackerResources()->
     2385        LoadResource('ICON', R_TrashIcon, &size);
     2386    if (data != NULL) {
     2387        trashDir->WriteAttr(kAttrLargeIcon, 'ICON', 0,
     2388            data, size);
     2389    }
     2390    data = GetTrackerResources()->
     2391        LoadResource('MICN', R_TrashIcon, &size);
     2392    if (data != NULL) {
     2393        trashDir->WriteAttr(kAttrMiniIcon, 'MICN', 0,
     2394            data, size);
     2395    }
     2396#ifdef __HAIKU__
     2397    data = GetTrackerResources()->
     2398        LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size);
     2399    if (data != NULL) {
     2400        trashDir->WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0,
     2401            data, size);
     2402    }
     2403#endif
     2404
    23742405    return B_OK;
    23752406}
    23762407
     
    28552886        find_directory(B_TRASH_DIRECTORY, &path, true, &volume);
    28562887
    28572888        BDirectory trashDir;
    2858         if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
    2859             // make trash invisible
    2860             StatStruct sbuf;
    2861             trashDir.GetStat(&sbuf);
    2862 
    2863             PoseInfo poseInfo;
    2864             poseInfo.fInvisible = true;
    2865             poseInfo.fInitedDirectory = sbuf.st_ino;
    2866             trashDir.WriteAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo,
    2867                 sizeof(PoseInfo));
    2868 
    2869             size_t size;
    2870             const void* data = GetTrackerResources()->
    2871                 LoadResource('ICON', R_TrashIcon, &size);
    2872             if (data != NULL) {
    2873                 trashDir.WriteAttr(kAttrLargeIcon, 'ICON', 0,
    2874                     data, size);
    2875             }
    2876             data = GetTrackerResources()->
    2877                 LoadResource('MICN', R_TrashIcon, &size);
    2878             if (data != NULL) {
    2879                 trashDir.WriteAttr(kAttrMiniIcon, 'MICN', 0,
    2880                     data, size);
    2881             }
    2882 #ifdef __HAIKU
    2883             data = GetTrackerResources()->
    2884                 LoadResource(B_VECTOR_ICON_TYPE, R_TrashIcon, &size);
    2885             if (data != NULL) {
    2886                 trashDir.WriteAttr(kAttrIcon, B_VECTOR_ICON_TYPE, 0,
    2887                     data, size);
    2888             }
    2889 #endif
    2890         }
     2889        FSGetTrashDir(&trashDir, volume.Device());
    28912890    }
    28922891}
    28932892