2 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3 * Distributed under the terms of the MIT/X11 license.
5 * Copyright (c) 1999 Mike Steed. You are free to use and distribute this software
6 * as long as it is accompanied by it's documentation and this copyright notice.
7 * The software comes with no warranty, etc.
16 #include <Directory.h>
23 static const char* kFileType
= B_FILE_MIME_TYPE
;
24 static const char* kDirType
= "application/x-vnd.Be-directory";
25 static const char* kVolumeType
= "application/x-vnd.Be-volume";
41 while (children
.size() != 0) {
42 FileInfo
* child
= *children
.begin();
44 children
.erase(children
.begin());
50 FileInfo::GetPath(string
& path
) const
53 path
.assign(ref
.name
);
55 BEntry
entry(&ref
, true);
56 BPath
pathObj(&entry
);
57 path
.assign(pathObj
.Path());
63 FileInfo::FindChild(const char* name
) const
65 vector
<FileInfo
*>::const_iterator i
= children
.begin();
66 while (i
!= children
.end()) {
67 if (strcmp((*i
)->ref
.name
, name
) == 0)
77 FileInfo::Type() const
79 char mimeStr
[B_MIME_TYPE_LENGTH
] = { '\0' };
81 // This is the volume's root directory; treat it as a volume type.
82 strlcpy(mimeStr
, kVolumeType
, sizeof(mimeStr
));
84 // Get the MIME type from the registrar.
86 if (node
.InitCheck() == B_OK
) {
87 BNodeInfo
nodeInfo(&node
);
88 if (nodeInfo
.InitCheck() == B_OK
) {
89 status_t s
= nodeInfo
.GetType(mimeStr
);
90 if (s
!= B_OK
&& children
.size() > 0) {
91 if (s
== B_ENTRY_NOT_FOUND
) {
92 // This status appears to be returned only for files on
93 // BFS volumes (e.g., CDFS volumes return B_BAD_VALUE).
94 //nodeInfo.SetType(kDirType);
96 strlcpy(mimeStr
, kDirType
, sizeof(mimeStr
));
102 if (strlen(mimeStr
) == 0)
103 strlcpy(mimeStr
, kFileType
, sizeof(mimeStr
));
105 return new BMimeType(mimeStr
);
112 VolumeSnapshot::VolumeSnapshot(const BVolume
* volume
)
114 char nameBuffer
[B_FILE_NAME_LENGTH
];
115 volume
->GetName(nameBuffer
);
118 capacity
= volume
->Capacity();
119 freeBytes
= volume
->FreeBytes();
125 VolumeSnapshot::~VolumeSnapshot()