本文整理汇总了C++中BFile::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BFile::GetSize方法的具体用法?C++ BFile::GetSize怎么用?C++ BFile::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFile
的用法示例。
在下文中一共展示了BFile::GetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetBounceMsg
void MailingList::SetBounceMsg(std::string path)
{
//attempt to read the custom bounce message file
BFile bouncemsgbfile;
status_t bouncemsgfilestatus=bouncemsgbfile.SetTo(path.c_str(),B_READ_ONLY);
if (bouncemsgfilestatus==B_NO_ERROR)
{
off_t bytes; //size of file
if (bouncemsgbfile.GetSize(&bytes) == B_NO_ERROR)
{
char* buff = new char[bytes];
off_t bytesread=bouncemsgbfile.Read(buff,bytes);
if ( (bytesread > 0) && (bytesread < 50001) )
{
//file read ok
std::string oldbouncemsg=fUnauthorisedBounceMsgContents; //save generic bounce msg so it can be appended later
fUnauthorisedBounceMsgContents=""; //clear existing contents
for (int x=0; x < bytesread; x++)
{
fUnauthorisedBounceMsgContents=fUnauthorisedBounceMsgContents+buff[x];
}
fUnauthorisedBounceMsgContents=fUnauthorisedBounceMsgContents+"\n\n"+oldbouncemsg; //append generic msg
}
delete buff;
}
bouncemsgbfile.Unset(); //close file
}
}
示例2: p
Emoconfig::Emoconfig(const char* xmlfile): BMessage()
{
fEmoticonSize = 16.0; //default
numfaces = 0;
fParser = XML_ParserCreate(NULL);
XML_SetUserData(fParser, this);
XML_SetElementHandler(fParser, StartElement, EndElement);
XML_SetCharacterDataHandler(fParser, Characters);
//path!
BPath p(xmlfile);
p.GetParent(&path);
// loading the config file..
BFile* settings = new BFile(xmlfile, B_READ_ONLY);
off_t size;
settings->GetSize(&size);
if (size) {
void* buffer = malloc((size_t)size);
size = settings->Read(buffer, (size_t)size);
XML_Parse(fParser, (const char*)buffer, (int)size, true);
free(buffer);
}
delete settings;
if (fParser)
XML_ParserFree(fParser);
printf("Emoconfig: loaded %d faces\n", numfaces);
}
示例3: Load
void Filters::Load()
{
status_t err;
// figure out where the file should be
BPath path;
err = find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
if (err != B_NO_ERROR)
return;
path.Append(FileNames::filtersFileName);
// open the file
BFile* file = new BFile(path.Path(), B_READ_ONLY);
if (file->InitCheck() != B_NO_ERROR) {
delete file;
return;
}
// load the text
off_t fileSize;
file->GetSize(&fileSize);
char* text = new char[fileSize];
file->ReadAt(0, text, fileSize);
delete file;
// parse it
TextReader reader(string_slice(text, text + fileSize));
FilterGroup* curGroup = NULL;
while (!reader.AtEOF()) {
// get the groupName
string_slice groupName = reader.NextTabField();
if (groupName.length() > 0) {
curGroup = GetFilterGroup(groupName);
if (curGroup == NULL) {
curGroup = new FilterGroup(groupName);
AddFilterGroup(curGroup);
}
reader.NextLine();
}
// if none, this is a filter line (if it's not blank)
else {
string_slice filterLine = reader.NextLine();
if (filterLine.length() > 0 && curGroup != NULL) {
Filter* filter = new Filter();
TextReader lineReader(filterLine);
filter->ReadFrom(&lineReader);
curGroup->AddFilter(filter);
}
}
}
// clean up
delete text;
}
示例4:
status_t
get_named_icon(const char* name, uint8** _data, size_t* _size, type_code* _type)
{
if (name == NULL || _data == NULL || _size == NULL || _type == NULL)
return B_BAD_VALUE;
directory_which kWhich[] = {
B_USER_DATA_DIRECTORY,
B_COMMON_DATA_DIRECTORY,
B_BEOS_DATA_DIRECTORY,
};
status_t status = B_ENTRY_NOT_FOUND;
BFile file;
off_t size;
for (uint32 i = 0; i < sizeof(kWhich) / sizeof(kWhich[0]); i++) {
BPath path;
if (find_directory(kWhich[i], &path) != B_OK)
continue;
path.Append("icons");
path.Append(name);
status = file.SetTo(path.Path(), B_READ_ONLY);
if (status == B_OK) {
status = file.GetSize(&size);
if (size > 1024 * 1024)
status = B_ERROR;
}
if (status == B_OK)
break;
}
if (status != B_OK)
return status;
*_data = new(std::nothrow) uint8[size];
if (*_data == NULL)
return B_NO_MEMORY;
if (file.Read(*_data, size) != size) {
delete[] *_data;
return B_ERROR;
}
*_size = size;
*_type = B_VECTOR_ICON_TYPE;
// TODO: for now
return B_OK;
}
示例5: sizeof
status_t
PictureView::_LoadPicture(const entry_ref* ref)
{
BFile file;
status_t status = file.SetTo(ref, B_READ_ONLY);
if (status != B_OK)
return status;
off_t fileSize;
status = file.GetSize(&fileSize);
if (status != B_OK)
return status;
// Check that we've at least some data to translate...
if (fileSize < 1)
return B_OK;
translator_info info;
memset(&info, 0, sizeof(translator_info));
BMessage ioExtension;
BTranslatorRoster* roster = BTranslatorRoster::Default();
if (roster == NULL)
return B_ERROR;
status = roster->Identify(&file, &ioExtension, &info, 0, NULL,
B_TRANSLATOR_BITMAP);
BBitmapStream stream;
if (status == B_OK) {
status = roster->Translate(&file, &info, &ioExtension, &stream,
B_TRANSLATOR_BITMAP);
}
if (status != B_OK)
return status;
BBitmap* picture = NULL;
if (stream.DetachBitmap(&picture) != B_OK
|| picture == NULL)
return B_ERROR;
// Remember image format so we could store using the same
fPictureMIMEType = info.MIME;
fPictureType = info.type;
_SetPicture(picture);
return B_OK;
}
示例6: BNodeInfo
void
TSigTextView::MessageReceived(BMessage *msg)
{
char type[B_FILE_NAME_LENGTH];
char *text;
int32 end;
int32 start;
BFile file;
BNodeInfo *node;
entry_ref ref;
off_t size;
switch (msg->what) {
case B_SIMPLE_DATA:
if (msg->HasRef("refs")) {
msg->FindRef("refs", &ref);
file.SetTo(&ref, O_RDONLY);
if (file.InitCheck() == B_NO_ERROR) {
node = new BNodeInfo(&file);
node->GetType(type);
delete node;
file.GetSize(&size);
if ((!strncasecmp(type, "text/", 5)) && (size)) {
text = (char *)malloc(size);
file.Read(text, size);
Delete();
GetSelection(&start, &end);
Insert(text, size);
Select(start, start + size);
free(text);
}
}
}
else
BTextView::MessageReceived(msg);
break;
case M_SELECT:
if (IsSelectable())
Select(0, TextLength());
break;
default:
BTextView::MessageReceived(msg);
}
}
示例7: CreateOutputFilePointer
/***********************************************************
* ProcessCommand
***********************************************************/
status_t
PGP::ProcessCommand(const char* cmd ,const char* in,BString *out)
{
BFile file;
status_t err = B_OK;
// Delete tmp files
DeleteFiles();
// Create an input tmp file
if(strlen(in) > 0)
{
PRINT(("PGPIN:%s\n",in));
if(CreateInputFilePointer(&file) != B_OK)
return B_ERROR;
file.Write(in, ::strlen(in));
file.Unset();
}
// Excute pgp command
PRINT(("PGPCMD:%s\n",cmd));
::system(cmd);
if(out)
{
// Create output file pointer
err = CreateOutputFilePointer(&file);
// Read output file
if(err == B_OK)
{
off_t size;
file.GetSize(&size);
if(size != 0)
{
out->SetTo("");
char *buf = out->LockBuffer(size+1);
size = file.Read(buf,size);
buf[size] = '\0';
out->UnlockBuffer();
}
}
PRINT(("PGPOUT:%s\n",out->String()));
}
// Delete tmp files
DeleteFiles();
return err;
}
示例8: Exception
// _InitPEFFile
void
ResourceFile::_InitPEFFile(BFile& file, const PEFContainerHeader& pefHeader)
{
status_t error = B_OK;
// get the file size
off_t fileSize = 0;
error = file.GetSize(&fileSize);
if (error != B_OK)
throw Exception(error, "Failed to get the file size.");
// check architecture -- we support PPC only
if (memcmp(pefHeader.architecture, kPEFArchitecturePPC, 4))
throw Exception("PEF file architecture is not PPC.");
fHostEndianess = B_HOST_IS_BENDIAN;
// get the section count
uint16 sectionCount = _GetUInt16(pefHeader.sectionCount);
// iterate through the PEF sections headers
uint32 sectionHeaderTableOffset = kPEFContainerHeaderSize;
uint32 sectionHeaderTableEnd
= sectionHeaderTableOffset + sectionCount * kPEFSectionHeaderSize;
uint32 resourceOffset = sectionHeaderTableEnd;
for (int32 i = 0; i < (int32)sectionCount; i++) {
uint32 shOffset = sectionHeaderTableOffset + i * kPEFSectionHeaderSize;
PEFSectionHeader sectionHeader;
read_exactly(file, shOffset, §ionHeader, kPEFSectionHeaderSize,
"Failed to read PEF section header.");
// get the header values
uint32 offset = _GetUInt32(sectionHeader.containerOffset);
uint32 size = _GetUInt32(sectionHeader.packedSize);
// check the values
if (offset < sectionHeaderTableEnd || offset > fileSize) {
throw Exception("Invalid PEF section header: invalid "
"section offset: %lu.", offset);
}
uint32 sectionEnd = offset + size;
if (sectionEnd > fileSize) {
throw Exception("Invalid PEF section header: section "
"exceeds file: %lu.", sectionEnd);
}
resourceOffset = max(resourceOffset, sectionEnd);
}
// init the offset file
fFile.SetTo(file, resourceOffset);
}
示例9:
status_t
KeyboardLayout::Load(entry_ref& ref)
{
BFile file;
status_t status = file.SetTo(&ref, B_READ_ONLY);
if (status != B_OK)
return status;
off_t size;
status = file.GetSize(&size);
if (status != B_OK)
return status;
if (size > 65536) {
// We don't accept files larger than this
return B_BAD_VALUE;
}
char* data = (char*)malloc(size + 1);
if (data == NULL)
return B_NO_MEMORY;
ssize_t bytesRead = file.Read(data, size);
if (bytesRead != size) {
free(data);
if (bytesRead < 0)
return bytesRead;
return B_IO_ERROR;
}
data[size] = '\0';
status = _InitFrom(data);
if (status == B_OK)
fIsDefault = false;
free(data);
return status;
}
示例10: memIO
status_t
DefaultCatalog::ReadFromFile(const char *path)
{
if (!path)
path = fPath.String();
BFile catalogFile;
status_t res = catalogFile.SetTo(path, B_READ_ONLY);
if (res != B_OK)
return B_ENTRY_NOT_FOUND;
fPath = path;
off_t sz = 0;
res = catalogFile.GetSize(&sz);
if (res != B_OK) {
return res;
}
auto_ptr<char> buf(new(std::nothrow) char [sz]);
if (buf.get() == NULL)
return B_NO_MEMORY;
res = catalogFile.Read(buf.get(), sz);
if (res < B_OK)
return res;
if (res < sz)
return res;
BMemoryIO memIO(buf.get(), sz);
res = Unflatten(&memIO);
if (res == B_OK) {
// some information living in member variables needs to be copied
// to attributes. Although these attributes should have been written
// when creating the catalog, we make sure that they exist there:
UpdateAttributes(catalogFile);
}
return res;
}
示例11: MessageReceived
void MarkupWindow::MessageReceived(BMessage* msg)
{
switch(msg->what)
{
case LOAD_CONTENT:
selected = topicListView->CurrentSelection();
if(selected >= 0) // you selected something
{
HelpStringItem* item;
BString contentPath = GetAppDirPath();
BFile file;
item = dynamic_cast<HelpStringItem*>(topicListView->ItemAt(selected));
contentPath += "/";
contentPath += item->ReturnContent();
printf("contentpath: %s\n", contentPath.String());
if(file.SetTo(contentPath, B_READ_ONLY) == B_OK)
{
off_t length;
char* text;
file.GetSize(&length);
text = (char*) malloc(length);
if(text && (file.Read(text, length)) >= B_OK)
{
contentTextView->SetText(text, length);
}
free(text);
}
}
break;
default:
{
BWindow::MessageReceived(msg);
break;
}
}
}
示例12: malloc
void
process_refs(entry_ref ref, BMessage* msg, void* reserved)
{
int32 buttonIndex= 0;
int32 prefsset=0;
BFile file;
char confirm = 'y';
char showStatus = 'y';
char *iterations;
int32 entryCount = 0;
entry_ref fref;
// Get the config
if (file.SetTo("/boot/home/config/settings/Shredder.conf", B_READ_ONLY) == B_OK) {
off_t length;
file.GetSize(&length); // Get the file length;
iterations = (char *) malloc(length);
file.Read(iterations, length);
confirm = iterations[2];
showStatus = iterations[3];
free(iterations);
}
// Got the config
if ((confirm != 'n') && (msg->FindRef("refs", 0, &fref) == B_OK)) {
BAlert *shredAlert = new BAlert(B_TRANSLATE_SYSTEM_NAME("Shredder"),
B_TRANSLATE("Are you sure you want to continue shredding?"),
B_TRANSLATE("Yes"), B_TRANSLATE("Preferences" B_UTF8_ELLIPSIS), B_TRANSLATE("Cancel"));
shredAlert->SetShortcut(2, B_ESCAPE);
buttonIndex = shredAlert->Go();
}
if (buttonIndex==2) {
return;
}
if (buttonIndex==1) {
PAppWindow * prefsWindow = new PAppWindow(/*ref, msg*/);
thread_id thread = prefsWindow->Thread();
//wait for the window thread to return
status_t win_status = B_OK;
wait_for_thread(thread, &win_status);
prefsset=1;
}
if ((prefsset==0) && (msg->FindRef("refs", 0, &fref) == B_OK)) {
for(int32 count = 0 ; msg->FindRef("refs", count, &fref) == B_OK ; count++) {
PStatWindow * statWindow = new PStatWindow(fref, msg, showStatus);
thread_id thread = statWindow->Thread();
status_t win_status = B_OK;
wait_for_thread(thread, &win_status);
entryCount++;
}
}
if ((entryCount == 0) && (prefsset==0)) {
PAppWindow * prefsWindow = new PAppWindow(/*ref, msg*/);
thread_id thread = prefsWindow->Thread();
//wait for the window thread to return
status_t win_status = B_OK;
wait_for_thread(thread, &win_status);
}
}
示例13: if
status_t
TRoster::_LoadRosterSettings(const char* path)
{
BPath _path;
const char* settingsPath
= path ? path : get_default_roster_settings_path(_path, false);
RosterSettingsCharStream stream;
status_t error;
BFile file;
error = file.SetTo(settingsPath, B_READ_ONLY);
off_t size;
if (!error)
error = file.GetSize(&size);
char* data = NULL;
if (!error) {
data = new(nothrow) char[size + 1];
error = data ? B_OK : B_NO_MEMORY;
}
if (!error) {
ssize_t bytes = file.Read(data, size);
error = bytes < 0 ? bytes : (bytes == size ? B_OK : B_FILE_ERROR);
}
if (!error) {
data[size] = 0;
error = stream.SetTo(std::string(data));
}
delete[] data;
if (!error) {
// Clear the current lists as
// we'll be manually building them up
fRecentDocuments.Clear();
fRecentFolders.Clear();
fRecentApps.Clear();
// Now we just walk through the file and read in the info
while (true) {
status_t streamError;
char str[B_PATH_NAME_LENGTH];
// (RecentDoc | RecentFolder | RecentApp)
streamError = stream.GetString(str);
if (!streamError) {
enum EntryType {
etDoc,
etFolder,
etApp,
etSomethingIsAmiss,
} type;
if (strcmp(str, "RecentDoc") == 0)
type = etDoc;
else if (strcmp(str, "RecentFolder") == 0)
type = etFolder;
else if (strcmp(str, "RecentApp") == 0)
type = etApp;
else
type = etSomethingIsAmiss;
switch (type) {
case etDoc:
case etFolder:
{
// For curing laziness
std::list<recent_entry*>* list = type == etDoc
? &fRecentDocuments.fEntryList
: &fRecentFolders.fEntryList;
char path[B_PATH_NAME_LENGTH];
char app[B_PATH_NAME_LENGTH];
char rank[B_PATH_NAME_LENGTH];
entry_ref ref;
ulong index = 0;
// Convert the given path to an entry ref
streamError = stream.GetString(path);
if (!streamError)
streamError = get_ref_for_path(path, &ref);
// Add a new entry to the list for each application
// signature and rank we find
while (!streamError) {
if (!streamError)
streamError = stream.GetString(app);
if (!streamError) {
BPrivate::Storage::to_lower(app);
streamError = stream.GetString(rank);
}
if (!streamError) {
index = strtoul(rank, NULL, 10);
if (index == ULONG_MAX)
streamError = errno;
}
recent_entry* entry = NULL;
if (!streamError) {
//.........这里部分代码省略.........
示例14: small
void
print_tga_info(BFile &file)
{
uint8 buf[TGA_HEADERS_SIZE];
// read in TGA headers
ssize_t size = TGA_HEADERS_SIZE;
if (size > 0 && file.Read(buf, size) != size) {
printf(B_TRANSLATE("Error: unable to read all TGA headers\n"));
return;
}
// TGA file header
TGAFileHeader fh;
fh.idlength = buf[0];
fh.colormaptype = buf[1];
fh.imagetype = buf[2];
printf(B_TRANSLATE("\nFile Header:\n"));
printf(B_TRANSLATE(" id length: %d\n"), static_cast<int>(fh.idlength));
printf(B_TRANSLATE("colormap type: %d (%s)\n"),
static_cast<int>(fh.colormaptype),
static_cast<const char *>(colormaptype(fh.colormaptype)));
printf(B_TRANSLATE(" image type: %d (%s)\n"),
static_cast<int>(fh.imagetype),
static_cast<const char *>(imagetype(fh.imagetype)));
// TGA color map spec
TGAColorMapSpec mapspec;
mapspec.firstentry = tga_uint16(reinterpret_cast<char *>(buf), 3);
mapspec.length = tga_uint16(reinterpret_cast<char *>(buf), 5);
mapspec.entrysize = buf[7];
printf(B_TRANSLATE("\nColormap Spec:\n"));
printf(B_TRANSLATE("first entry: %d\n"),
static_cast<int>(mapspec.firstentry));
printf(B_TRANSLATE(" length: %d\n"),
static_cast<int>(mapspec.length));
printf(B_TRANSLATE(" entry size: %d\n"),
static_cast<int>(mapspec.entrysize));
// TGA image spec
TGAImageSpec imagespec;
imagespec.xorigin = tga_uint16(reinterpret_cast<char *>(buf), 8);
imagespec.yorigin = tga_uint16(reinterpret_cast<char *>(buf), 10);
imagespec.width = tga_uint16(reinterpret_cast<char *>(buf), 12);
imagespec.height = tga_uint16(reinterpret_cast<char *>(buf), 14);
imagespec.depth = buf[16];
imagespec.descriptor = buf[17];
printf(B_TRANSLATE("\nImage Spec:\n"));
printf(B_TRANSLATE(" x origin: %d\n"),
static_cast<int>(imagespec.xorigin));
printf(B_TRANSLATE(" y origin: %d\n"),
static_cast<int>(imagespec.yorigin));
printf(B_TRANSLATE(" width: %d\n"),
static_cast<int>(imagespec.width));
printf(B_TRANSLATE(" height: %d\n"),
static_cast<int>(imagespec.height));
printf(B_TRANSLATE(" depth: %d\n"),
static_cast<int>(imagespec.depth));
printf(B_TRANSLATE("descriptor: 0x%.2x\n"),
static_cast<int>(imagespec.descriptor));
printf(B_TRANSLATE("\talpha (attr): %d\n"),
static_cast<int>(imagespec.descriptor & TGA_DESC_ALPHABITS));
if (imagespec.descriptor & TGA_ORIGIN_VERT_BIT)
if (imagespec.descriptor & TGA_ORIGIN_HORZ_BIT)
printf(B_TRANSLATE("\t origin: %d (%s %s)\n"),
static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
| TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("top"),
static_cast<const char *>("right"));
else
printf(B_TRANSLATE("\t origin: %d (%s %s)\n"),
static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
| TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("top"),
static_cast<const char *>("left"));
else
if (imagespec.descriptor & TGA_ORIGIN_HORZ_BIT)
printf(B_TRANSLATE("\t origin: %d (%s %s)\n"),
static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
| TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("bottom"),
static_cast<const char *>("right"));
else
printf(B_TRANSLATE("\t origin: %d (%s %s)\n"),
static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
| TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("bottom"),
static_cast<const char *>("left"));
printf(B_TRANSLATE("\t bits 7 & 6: %d\n"),
static_cast<int>(imagespec.descriptor & TGA_DESC_BITS76));
// Optional TGA Footer
off_t filesize = 0;
if (file.GetSize(&filesize) == B_OK) {
//.........这里部分代码省略.........
示例15: ParseDateWithTimeZone
BMailFilterAction
HaikuMailFormatFilter::HeaderFetched(entry_ref& ref, BFile& file,
BMessage& attributes)
{
file.Seek(0, SEEK_SET);
// TODO: attributes.AddInt32(B_MAIL_ATTR_CONTENT, length);
attributes.AddInt32(B_MAIL_ATTR_ACCOUNT_ID, fAccountID);
attributes.AddString(B_MAIL_ATTR_ACCOUNT, fAccountName);
BString header;
off_t size;
if (file.GetSize(&size) == B_OK) {
char* buffer = header.LockBuffer(size);
if (buffer == NULL)
return B_NO_MEMORY;
ssize_t bytesRead = file.Read(buffer, size);
if (bytesRead < 0)
return bytesRead;
if (bytesRead != size)
return B_IO_ERROR;
header.UnlockBuffer(size);
}
for (int i = 0; gDefaultFields[i].rfc_name; ++i) {
BString target;
status_t status = extract_from_header(header,
gDefaultFields[i].rfc_name, target);
if (status != B_OK)
continue;
switch (gDefaultFields[i].attr_type){
case B_STRING_TYPE:
sanitize_white_space(target);
attributes.AddString(gDefaultFields[i].attr_name, target);
break;
case B_TIME_TYPE:
{
time_t when;
when = ParseDateWithTimeZone(target);
if (when == -1)
when = time(NULL); // Use current time if it's undecodable.
attributes.AddData(B_MAIL_ATTR_WHEN, B_TIME_TYPE, &when,
sizeof(when));
break;
}
}
}
BString senderName = _ExtractName(attributes.FindString(B_MAIL_ATTR_FROM));
attributes.AddString(B_MAIL_ATTR_NAME, senderName);
// Generate a file name for the incoming message. See also
// Message::RenderTo which does a similar thing for outgoing messages.
BString name = attributes.FindString(B_MAIL_ATTR_SUBJECT);
SubjectToThread(name); // Extract the core subject words.
if (name.Length() <= 0)
name = "No Subject";
attributes.AddString(B_MAIL_ATTR_THREAD, name);
// Convert the date into a year-month-day fixed digit width format, so that
// sorting by file name will give all the messages with the same subject in
// order of date.
time_t dateAsTime = 0;
const time_t* datePntr;
ssize_t dateSize;
char numericDateString[40];
struct tm timeFields;
if (attributes.FindData(B_MAIL_ATTR_WHEN, B_TIME_TYPE,
(const void**)&datePntr, &dateSize) == B_OK)
dateAsTime = *datePntr;
localtime_r(&dateAsTime, &timeFields);
snprintf(numericDateString, sizeof(numericDateString),
"%04d%02d%02d%02d%02d%02d",
timeFields.tm_year + 1900, timeFields.tm_mon + 1, timeFields.tm_mday,
timeFields.tm_hour, timeFields.tm_min, timeFields.tm_sec);
name << " " << numericDateString;
BString workerName = attributes.FindString(B_MAIL_ATTR_FROM);
extract_address_name(workerName);
name << " " << workerName;
name.Truncate(222); // reserve space for the unique number
// Get rid of annoying characters which are hard to use in the shell.
name.ReplaceAll('/', '_');
name.ReplaceAll('\'', '_');
name.ReplaceAll('"', '_');
name.ReplaceAll('!', '_');
name.ReplaceAll('<', '_');
name.ReplaceAll('>', '_');
_RemoveExtraWhitespace(name);
_RemoveLeadingDots(name);
// Avoid files starting with a dot.
if (!attributes.HasString(B_MAIL_ATTR_STATUS))
//.........这里部分代码省略.........