mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-02 16:29:57 +00:00
shared_ptr changes.
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@346 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
78d35bba08
commit
2243d8d136
@ -78,7 +78,7 @@ unsigned BlockDevice::ImageType(const char *type, unsigned defv)
|
||||
return defv;
|
||||
}
|
||||
|
||||
BlockDevice *BlockDevice::Open(const char *name, File::FileFlags flags, unsigned imageType)
|
||||
BlockDevicePointer BlockDevice::Open(const char *name, File::FileFlags flags, unsigned imageType)
|
||||
{
|
||||
#undef __METHOD__
|
||||
#define __METHOD__ "BlockDevice::Open"
|
||||
@ -128,7 +128,7 @@ BlockDevice *BlockDevice::Open(const char *name, File::FileFlags flags, unsigned
|
||||
}
|
||||
|
||||
// throw an error?
|
||||
return NULL;
|
||||
return BlockDevicePointer();
|
||||
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ static std::string filename(const std::string& src)
|
||||
}
|
||||
|
||||
|
||||
BlockDevice *BlockDevice::Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType)
|
||||
BlockDevicePointer BlockDevice::Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType)
|
||||
{
|
||||
std::string xname;
|
||||
|
||||
@ -191,7 +191,7 @@ BlockDevice *BlockDevice::Create(const char *fname, const char *vname, unsigned
|
||||
return DavexDiskImage::Create(fname, blocks, vname);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return BlockDevicePointer();
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ public:
|
||||
// static methods.
|
||||
static unsigned ImageType(const char *type, unsigned defv = 0);
|
||||
|
||||
static BlockDevice *Open(const char *name, File::FileFlags flags, unsigned imageType = 0);
|
||||
static BlockDevice *Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType = 0);
|
||||
static BlockDevicePointer Open(const char *name, File::FileFlags flags, unsigned imageType = 0);
|
||||
static BlockDevicePointer Create(const char *fname, const char *vname, unsigned blocks, unsigned imageType = 0);
|
||||
|
||||
|
||||
|
||||
|
@ -85,20 +85,20 @@ void DavexDiskImage::Validate(MappedFile *f)
|
||||
throw Exception(__METHOD__ ": Invalid file format.");
|
||||
}
|
||||
|
||||
DavexDiskImage *DavexDiskImage::Open(MappedFile *file)
|
||||
BlockDevicePointer DavexDiskImage::Open(MappedFile *file)
|
||||
{
|
||||
#undef __METHOD__
|
||||
#define __METHOD__ "DavexDiskImage::Open"
|
||||
Validate(file);
|
||||
|
||||
return new DavexDiskImage(file);
|
||||
return BlockDevicePointer(new DavexDiskImage(file));
|
||||
}
|
||||
|
||||
DavexDiskImage *DavexDiskImage::Create(const char *name, size_t blocks)
|
||||
BlockDevicePointer DavexDiskImage::Create(const char *name, size_t blocks)
|
||||
{
|
||||
return Create(name, blocks, "Untitled");
|
||||
}
|
||||
DavexDiskImage *DavexDiskImage::Create(const char *name, size_t blocks, const char *vname)
|
||||
BlockDevicePointer DavexDiskImage::Create(const char *name, size_t blocks, const char *vname)
|
||||
{
|
||||
#undef __METHOD__
|
||||
#define __METHOD__ "DavexDiskImage::Create"
|
||||
@ -154,7 +154,7 @@ DavexDiskImage *DavexDiskImage::Create(const char *name, size_t blocks, const ch
|
||||
std::memcpy(file->address(), header.buffer(), 512);
|
||||
file->sync();
|
||||
|
||||
return new DavexDiskImage(file);
|
||||
return BlockDevicePointer(new DavexDiskImage(file));
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,9 +16,9 @@ public:
|
||||
|
||||
virtual ~DavexDiskImage();
|
||||
|
||||
static DavexDiskImage *Create(const char *name, size_t blocks);
|
||||
static DavexDiskImage *Create(const char *name, size_t blocks, const char *vname);
|
||||
static DavexDiskImage *Open(MappedFile *);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks, const char *vname);
|
||||
static BlockDevicePointer Open(MappedFile *);
|
||||
|
||||
virtual BlockCachePointer createBlockCache();
|
||||
|
||||
|
@ -16,6 +16,7 @@ namespace Device {
|
||||
class BlockDevice;
|
||||
class BlockCache;
|
||||
|
||||
|
||||
typedef std::tr1::shared_ptr<BlockDevice> BlockDevicePointer;
|
||||
typedef std::tr1::shared_ptr<BlockCache> BlockCachePointer;
|
||||
|
||||
|
@ -75,10 +75,10 @@ uint32_t DiskCopy42Image::Checksum(void *data, size_t size)
|
||||
return rv;
|
||||
}
|
||||
|
||||
DiskCopy42Image *DiskCopy42Image::Open(MappedFile *f)
|
||||
BlockDevicePointer DiskCopy42Image::Open(MappedFile *f)
|
||||
{
|
||||
Validate(f);
|
||||
return new DiskCopy42Image(f);
|
||||
return BlockDevicePointer(new DiskCopy42Image(f));
|
||||
}
|
||||
|
||||
static uint8_t DiskFormat(size_t blocks)
|
||||
@ -101,12 +101,12 @@ static uint8_t FormatByte(size_t blocks)
|
||||
default: return 0x22;
|
||||
}
|
||||
}
|
||||
DiskCopy42Image *DiskCopy42Image::Create(const char *name, size_t blocks)
|
||||
BlockDevicePointer DiskCopy42Image::Create(const char *name, size_t blocks)
|
||||
{
|
||||
return Create(name, blocks, "Untitled");
|
||||
}
|
||||
|
||||
DiskCopy42Image *DiskCopy42Image::Create(const char *name, size_t blocks, const char *vname)
|
||||
BlockDevicePointer DiskCopy42Image::Create(const char *name, size_t blocks, const char *vname)
|
||||
{
|
||||
MappedFile *file = MappedFile::Create(name, blocks * 512 + oUserData);
|
||||
|
||||
@ -163,7 +163,7 @@ DiskCopy42Image *DiskCopy42Image::Create(const char *name, size_t blocks, const
|
||||
std::memcpy(file->address(), header.buffer(), oUserData);
|
||||
file->sync();
|
||||
|
||||
return new DiskCopy42Image(file);
|
||||
return BlockDevicePointer(new DiskCopy42Image(file));
|
||||
}
|
||||
|
||||
void DiskCopy42Image::Validate(MappedFile *file)
|
||||
|
@ -12,10 +12,10 @@ class DiskCopy42Image : public DiskImage {
|
||||
public:
|
||||
virtual ~DiskCopy42Image();
|
||||
|
||||
static DiskCopy42Image *Create(const char *name, size_t blocks);
|
||||
static DiskCopy42Image *Create(const char *name, size_t blocks, const char *vname);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks, const char *vname);
|
||||
|
||||
static DiskCopy42Image *Open(MappedFile *);
|
||||
static BlockDevicePointer Open(MappedFile *);
|
||||
|
||||
static uint32_t Checksum(void *data, size_t size);
|
||||
|
||||
|
@ -112,16 +112,16 @@ ProDOSOrderDiskImage::ProDOSOrderDiskImage(MappedFile *file) :
|
||||
setAdaptor(new POAdaptor(address()));
|
||||
}
|
||||
|
||||
ProDOSOrderDiskImage *ProDOSOrderDiskImage::Create(const char *name, size_t blocks)
|
||||
BlockDevicePointer ProDOSOrderDiskImage::Create(const char *name, size_t blocks)
|
||||
{
|
||||
MappedFile *file = MappedFile::Create(name, blocks * 512);
|
||||
return new ProDOSOrderDiskImage(file);
|
||||
return BlockDevicePointer(new ProDOSOrderDiskImage(file));
|
||||
}
|
||||
|
||||
ProDOSOrderDiskImage *ProDOSOrderDiskImage::Open(MappedFile *file)
|
||||
BlockDevicePointer ProDOSOrderDiskImage::Open(MappedFile *file)
|
||||
{
|
||||
Validate(file);
|
||||
return new ProDOSOrderDiskImage(file);
|
||||
return BlockDevicePointer(new ProDOSOrderDiskImage(file));
|
||||
}
|
||||
|
||||
void ProDOSOrderDiskImage::Validate(MappedFile *f)
|
||||
@ -165,16 +165,16 @@ DOSOrderDiskImage::DOSOrderDiskImage(MappedFile *file) :
|
||||
}
|
||||
|
||||
|
||||
DOSOrderDiskImage *DOSOrderDiskImage::Create(const char *name, size_t blocks)
|
||||
BlockDevicePointer DOSOrderDiskImage::Create(const char *name, size_t blocks)
|
||||
{
|
||||
MappedFile *file = MappedFile::Create(name, blocks * 512);
|
||||
return new DOSOrderDiskImage(file);
|
||||
return BlockDevicePointer(new DOSOrderDiskImage(file));
|
||||
}
|
||||
|
||||
DOSOrderDiskImage *DOSOrderDiskImage::Open(MappedFile *file)
|
||||
BlockDevicePointer DOSOrderDiskImage::Open(MappedFile *file)
|
||||
{
|
||||
Validate(file);
|
||||
return new DOSOrderDiskImage(file);
|
||||
return BlockDevicePointer(new DOSOrderDiskImage(file));
|
||||
}
|
||||
|
||||
void DOSOrderDiskImage::Validate(MappedFile *f)
|
||||
|
@ -57,8 +57,8 @@ class ProDOSOrderDiskImage : public DiskImage {
|
||||
public:
|
||||
|
||||
|
||||
static ProDOSOrderDiskImage *Create(const char *name, size_t blocks);
|
||||
static ProDOSOrderDiskImage *Open(MappedFile *);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks);
|
||||
static BlockDevicePointer Open(MappedFile *);
|
||||
|
||||
|
||||
virtual BlockCachePointer createBlockCache();
|
||||
@ -75,8 +75,8 @@ class DOSOrderDiskImage : public DiskImage {
|
||||
public:
|
||||
|
||||
|
||||
static DOSOrderDiskImage *Create(const char *name, size_t blocks);
|
||||
static DOSOrderDiskImage *Open(MappedFile *);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks);
|
||||
static BlockDevicePointer Open(MappedFile *);
|
||||
|
||||
private:
|
||||
DOSOrderDiskImage();
|
||||
|
@ -196,9 +196,9 @@ RawDevice::~RawDevice()
|
||||
}
|
||||
|
||||
|
||||
RawDevice *RawDevice::Open(const char *name, File::FileFlags flags)
|
||||
BlockDevicePointer RawDevice::Open(const char *name, File::FileFlags flags)
|
||||
{
|
||||
return new RawDevice(name, flags);
|
||||
return BlockDevicePointer(new RawDevice(name, flags));
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
|
||||
|
||||
|
||||
static RawDevice *Open(const char *name, File::FileFlags flags);
|
||||
static BlockDevicePointer Open(const char *name, File::FileFlags flags);
|
||||
|
||||
|
||||
virtual ~RawDevice();
|
||||
|
@ -41,7 +41,7 @@ UniversalDiskImage::UniversalDiskImage(MappedFile *file) :
|
||||
setAdaptor(new POAdaptor(_dataOffset + data));
|
||||
}
|
||||
|
||||
UniversalDiskImage *UniversalDiskImage::Create(const char *name, size_t blocks)
|
||||
BlockDevicePointer UniversalDiskImage::Create(const char *name, size_t blocks)
|
||||
{
|
||||
// 64-byte header.
|
||||
MappedFile *file = MappedFile::Create(name, blocks * 512 + 64);
|
||||
@ -81,13 +81,13 @@ UniversalDiskImage *UniversalDiskImage::Create(const char *name, size_t blocks)
|
||||
std::memcpy(file->address(), header.buffer(), 64);
|
||||
|
||||
|
||||
return new UniversalDiskImage(file);
|
||||
return BlockDevicePointer(new UniversalDiskImage(file));
|
||||
}
|
||||
|
||||
UniversalDiskImage *UniversalDiskImage::Open(MappedFile *file)
|
||||
BlockDevicePointer UniversalDiskImage::Open(MappedFile *file)
|
||||
{
|
||||
Validate(file);
|
||||
return new UniversalDiskImage(file);
|
||||
return BlockDevicePointer(new UniversalDiskImage(file));
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,8 +14,8 @@ public:
|
||||
|
||||
|
||||
|
||||
static UniversalDiskImage *Create(const char *name, size_t blocks);
|
||||
static UniversalDiskImage *Open(MappedFile *);
|
||||
static BlockDevicePointer Create(const char *name, size_t blocks);
|
||||
static BlockDevicePointer Open(MappedFile *);
|
||||
|
||||
virtual bool readOnly();
|
||||
|
||||
|
@ -72,11 +72,10 @@ VolumeEntry::VolumeEntry()
|
||||
setInode(1);
|
||||
|
||||
_inodeGenerator = 1;
|
||||
_cache = NULL;
|
||||
_device = NULL;
|
||||
}
|
||||
|
||||
VolumeEntry::VolumeEntry(const char *name, Device::BlockDevice *device)
|
||||
VolumeEntry::VolumeEntry(const char *name, Device::BlockDevicePointer device) :
|
||||
_device(device)
|
||||
{
|
||||
#undef __METHOD__
|
||||
#define __METHOD__ "VolumeEntry::VolumeEntry"
|
||||
@ -114,8 +113,8 @@ VolumeEntry::VolumeEntry(const char *name, Device::BlockDevice *device)
|
||||
_accessTime = 0;
|
||||
_lastBoot = Date::Today();
|
||||
|
||||
_cache = BlockCache::Create(device);
|
||||
_device = device;
|
||||
_cache = BlockCache::Create(device);
|
||||
|
||||
_address = 512 * 2;
|
||||
|
||||
@ -136,10 +135,10 @@ VolumeEntry::VolumeEntry(const char *name, Device::BlockDevice *device)
|
||||
}
|
||||
|
||||
|
||||
VolumeEntry::VolumeEntry(Device::BlockDevice *device)
|
||||
VolumeEntry::VolumeEntry(Device::BlockDevicePointer device)
|
||||
{
|
||||
unsigned blockCount;
|
||||
unsigned deviceBlocks = device->blocks();
|
||||
//unsigned deviceBlocks = device->blocks();
|
||||
ProFUSE::auto_array<uint8_t> buffer(new uint8_t[512]);
|
||||
|
||||
|
||||
@ -246,9 +245,6 @@ VolumeEntry::~VolumeEntry()
|
||||
if (*iter) delete *iter;
|
||||
}
|
||||
|
||||
delete _cache;
|
||||
// _device is deleted by _cache.
|
||||
//delete _device;
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,10 +19,10 @@ namespace Pascal {
|
||||
|
||||
|
||||
// create new
|
||||
VolumeEntry(const char *name, Device::BlockDevice *);
|
||||
VolumeEntry(const char *name, Device::BlockDevicePointer);
|
||||
|
||||
// open existing
|
||||
VolumeEntry(Device::BlockDevice *);
|
||||
VolumeEntry(Device::BlockDevicePointer);
|
||||
virtual ~VolumeEntry();
|
||||
|
||||
const char *name() const { return _fileName; }
|
||||
@ -93,8 +93,8 @@ namespace Pascal {
|
||||
std::vector<FileEntry *> _files;
|
||||
unsigned _inodeGenerator;
|
||||
|
||||
Device::BlockDevice *_device;
|
||||
Device::BlockCache *_cache;
|
||||
Device::BlockDevicePointer _device;
|
||||
Device::BlockCachePointer _cache;
|
||||
};
|
||||
|
||||
|
||||
|
10
bin/apfm.cpp
10
bin/apfm.cpp
@ -5,7 +5,6 @@
|
||||
* E -
|
||||
*/
|
||||
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
@ -23,6 +22,7 @@
|
||||
#include <Pascal/Date.h>
|
||||
#include <Pascal/TextWriter.h>
|
||||
|
||||
#include <Device/Device.h>
|
||||
#include <Device/BlockDevice.h>
|
||||
|
||||
#include <File/File.h>
|
||||
@ -963,7 +963,7 @@ int action_put(int argc, char **argv, Pascal::VolumeEntry *volume)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::auto_ptr<Pascal::VolumeEntry> volume;
|
||||
std::auto_ptr<Device::BlockDevice> device;
|
||||
Device::BlockDevicePointer device;
|
||||
|
||||
unsigned fmt = 0;
|
||||
|
||||
@ -1025,10 +1025,10 @@ int main(int argc, char **argv)
|
||||
|
||||
unsigned actionCode = command(action);
|
||||
|
||||
device.reset( Device::BlockDevice::Open(file, commandFlags(actionCode), fmt) );
|
||||
device = Device::BlockDevice::Open(file, commandFlags(actionCode), fmt);
|
||||
|
||||
volume.reset( new Pascal::VolumeEntry(device.get()));
|
||||
device.release();
|
||||
volume.reset( new Pascal::VolumeEntry(device));
|
||||
device.reset();
|
||||
|
||||
switch (actionCode)
|
||||
{
|
||||
|
@ -17,17 +17,18 @@
|
||||
#include <fuse/fuse_opt.h>
|
||||
#include <fuse/fuse_lowlevel.h>
|
||||
|
||||
|
||||
#include <Pascal/Pascal.h>
|
||||
#include <ProFUSE/Exception.h>
|
||||
|
||||
#include <Device/BlockDevice.h>
|
||||
|
||||
#include <File/File.h>
|
||||
|
||||
#include <Device/Device.h>
|
||||
#include <Device/BlockDevice.h>
|
||||
|
||||
std::string fDiskImage;
|
||||
|
||||
|
||||
|
||||
void usage()
|
||||
{
|
||||
std::printf("profuse_pascal 0.1\n\n");
|
||||
@ -196,9 +197,11 @@ int main(int argc, char **argv)
|
||||
try
|
||||
{
|
||||
|
||||
std::auto_ptr<Device::BlockDevice> device;
|
||||
//std::tr1::shared_ptr<Device::BlockDevice> device;
|
||||
|
||||
device.reset( Device::BlockDevice::Open(fDiskImage.c_str(), File::ReadOnly, format) );
|
||||
Device::BlockDevicePointer device;
|
||||
|
||||
device = Device::BlockDevice::Open(fDiskImage.c_str(), File::ReadOnly, format);
|
||||
|
||||
|
||||
if (!device.get())
|
||||
@ -207,8 +210,8 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
volume.reset( new Pascal::VolumeEntry(device.get()) );
|
||||
device.release();
|
||||
volume.reset( new Pascal::VolumeEntry(device) );
|
||||
device.reset();
|
||||
}
|
||||
catch (ProFUSE::POSIXException &e)
|
||||
{
|
||||
|
@ -214,7 +214,7 @@ int main(int argc, char **argv)
|
||||
struct stat st;
|
||||
bool rawDevice;
|
||||
|
||||
std::auto_ptr<BlockDevice> device;
|
||||
BlockDevicePointer device;
|
||||
std::auto_ptr<VolumeEntry> volume;
|
||||
|
||||
// Check for block device. if so, verify.
|
||||
@ -228,7 +228,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "`%s' is a raw device. Are you sure you want to initialize it? ", fname);
|
||||
if (!yes_or_no()) return -1;
|
||||
|
||||
device.reset( RawDevice::Open(fname, File::ReadWrite) );
|
||||
device = RawDevice::Open(fname, File::ReadWrite);
|
||||
blocks = device->blocks();
|
||||
rawDevice = true;
|
||||
|
||||
@ -260,7 +260,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!rawDevice)
|
||||
device.reset( BlockDevice::Create(fname, volumeName.c_str(), blocks, format));
|
||||
device = BlockDevice::Create(fname, volumeName.c_str(), blocks, format);
|
||||
|
||||
if (!device.get())
|
||||
{
|
||||
@ -299,9 +299,8 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
volume.reset(
|
||||
new VolumeEntry(volumeName.c_str(), device.get())
|
||||
new VolumeEntry(volumeName.c_str(), device)
|
||||
);
|
||||
device.release();
|
||||
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define NEWFS_VERSION "0.1"
|
||||
|
||||
using namespace ProFUSE;
|
||||
using namespace Device;
|
||||
|
||||
void usage()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user