* follow hint by Axel: drop FDCloser and use shared class
FileDescriptorCloser instead git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40330 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*/
|
|
||||||
#ifndef _PACKAGE__HPKG__PRIVATE__FD_CLOSER_H_
|
|
||||||
#define _PACKAGE__HPKG__PRIVATE__FD_CLOSER_H_
|
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
|
||||||
|
|
||||||
namespace BHPKG {
|
|
||||||
|
|
||||||
namespace BPrivate {
|
|
||||||
|
|
||||||
|
|
||||||
struct FDCloser {
|
|
||||||
FDCloser(int fd)
|
|
||||||
:
|
|
||||||
fFD(fd)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~FDCloser()
|
|
||||||
{
|
|
||||||
if (fFD >= 0)
|
|
||||||
close(fFD);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int fFD;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
|
||||||
|
|
||||||
} // namespace BHPKG
|
|
||||||
|
|
||||||
} // namespace BPackageKit
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _PACKAGE__HPKG__PRIVATE__FD_CLOSER_H_
|
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
#include <Notifications.h>
|
#include <Notifications.h>
|
||||||
|
|
||||||
#include <package/hpkg/ErrorOutput.h>
|
#include <package/hpkg/ErrorOutput.h>
|
||||||
#include <package/hpkg/FDCloser.h>
|
|
||||||
#include <package/hpkg/PackageEntry.h>
|
#include <package/hpkg/PackageEntry.h>
|
||||||
#include <package/hpkg/PackageEntryAttribute.h>
|
#include <package/hpkg/PackageEntryAttribute.h>
|
||||||
#include <package/hpkg/PackageReaderImpl.h>
|
#include <package/hpkg/PackageReaderImpl.h>
|
||||||
|
|||||||
@@ -94,17 +94,6 @@ printf("Init(): %s\n", strerror(error));
|
|||||||
|| strcmp(entry->d_name, "..") == 0)
|
|| strcmp(entry->d_name, "..") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(entry->d_name, B_HPKG_PACKAGE_INFO_FILE_NAME) == 0) {
|
|
||||||
printf("parsing %s ...\n", entry->d_name);
|
|
||||||
struct ErrorListener : public BPackageInfo::ParseErrorListener {
|
|
||||||
virtual void OnError(const BString& msg, int line, int col) {
|
|
||||||
printf("*** parse error (%d:%d) -> %s\n", line, col, msg.String());
|
|
||||||
}
|
|
||||||
} errorListener;
|
|
||||||
BEntry packageInfoEntry(entry->d_name);
|
|
||||||
BPackageInfo packageInfo;
|
|
||||||
packageInfo.ReadFromConfigFile(packageInfoEntry, &errorListener);
|
|
||||||
}
|
|
||||||
error = packageWriter.AddEntry(entry->d_name);
|
error = packageWriter.AddEntry(entry->d_name);
|
||||||
printf("AddEntry(\"%s\"): %s\n", entry->d_name, strerror(error));
|
printf("AddEntry(\"%s\"): %s\n", entry->d_name, strerror(error));
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
|
|||||||
@@ -27,11 +27,13 @@
|
|||||||
|
|
||||||
#include <package/hpkg/DataOutput.h>
|
#include <package/hpkg/DataOutput.h>
|
||||||
#include <package/hpkg/DataReader.h>
|
#include <package/hpkg/DataReader.h>
|
||||||
#include <package/hpkg/FDCloser.h>
|
|
||||||
#include <package/hpkg/Stacker.h>
|
#include <package/hpkg/Stacker.h>
|
||||||
#include <package/hpkg/ZlibCompressor.h>
|
#include <package/hpkg/ZlibCompressor.h>
|
||||||
|
|
||||||
|
|
||||||
|
using BPrivate::FileDescriptorCloser;
|
||||||
|
|
||||||
|
|
||||||
namespace BPackageKit {
|
namespace BPackageKit {
|
||||||
|
|
||||||
namespace BHPKG {
|
namespace BHPKG {
|
||||||
@@ -1089,7 +1091,7 @@ printf("PackageWriter::_AddEntry(%d, %p, \"%s\")\n", dirFD, entry, fileName);
|
|||||||
fileName, strerror(errno));
|
fileName, strerror(errno));
|
||||||
throw status_t(errno);
|
throw status_t(errno);
|
||||||
}
|
}
|
||||||
FDCloser fdCloser(fd);
|
FileDescriptorCloser fdCloser(fd);
|
||||||
|
|
||||||
// stat the node
|
// stat the node
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|||||||
Reference in New Issue
Block a user