From 05e13f91a5ba0f3649265df1cbd7ecad7147a74a Mon Sep 17 00:00:00 2001 From: ksherlock Date: Sat, 12 Dec 2009 15:38:12 +0000 Subject: [PATCH] git-svn-id: https://profuse.googlecode.com/svn/branches/v2@153 aa027e90-d47c-11dd-86d7-074df07e0730 --- pascal/Date.cpp | 5 +++-- pascal/Date.h | 3 ++- pascal/File.cpp | 19 ++++++++++--------- pascal/File.h | 6 +++--- pascal/IOBuffer.h | 5 +++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pascal/Date.cpp b/pascal/Date.cpp index 6efcb0d..5ccb29d 100644 --- a/pascal/Date.cpp +++ b/pascal/Date.cpp @@ -1,5 +1,6 @@ #include "Date.h" #include +#include using namespace Pascal; @@ -28,7 +29,7 @@ Date::operator std::time_t() const { return std::mktime(&tm); } -Date::operator unsigned() const { +Date::operator uint16_t() const { // year must be 0 .. 127 return (_year << 9) | (_day << 4) | _month; } @@ -40,5 +41,5 @@ Date Date::Today() ::localtime_r(&t, &tm); - return Date(tm.tm_year, tm.tm_month, tm.tm_mday); + return Date(tm.tm_year, tm.tm_mon, tm.tm_mday); } \ No newline at end of file diff --git a/pascal/Date.h b/pascal/Date.h index 510aa73..6387a80 100644 --- a/pascal/Date.h +++ b/pascal/Date.h @@ -2,6 +2,7 @@ #define __PASCAL_DATE_H__ #include +#include namespace Pascal { @@ -15,7 +16,7 @@ public: Date(unsigned); operator std::time_t() const; - operator unsigned() const; + operator uint16_t() const; unsigned month() const { return _month; } unsigned day() const { return _day; } diff --git a/pascal/File.cpp b/pascal/File.cpp index 7834a4e..adea791 100644 --- a/pascal/File.cpp +++ b/pascal/File.cpp @@ -3,6 +3,7 @@ #include "../Endian.h" #include "../BlockDevice.h" #include "../BlockCache.h" +#include "../Exception.h" #include "IOBuffer.h" @@ -48,7 +49,7 @@ unsigned Entry::ValidName(const char *cp, unsigned maxLength) if (!cp || !*cp) return 0; - if (!isalpaha(*cp)) return 0; + if (!isalpha(*cp)) return 0; for (length = 1; cp[length]; ++length) { @@ -129,7 +130,7 @@ VolumeEntry::VolumeEntry(const char *name, ProFUSE::BlockDevice *device) length = ValidName(name); if (!length) - throw Exception(__METHOD__ ": Invalid volume name."); + throw ProFUSE::Exception(__METHOD__ ": Invalid volume name."); _firstBlock = 2; _lastBlock = 6; @@ -148,7 +149,7 @@ VolumeEntry::VolumeEntry(const char *name, ProFUSE::BlockDevice *device) _lastVolumeBlock = device->blocks(); _fileCount = 0; _accessTime = 0; - _lastBoot = Date.Today(); + _lastBoot = Date::Today(); _cache = device->blockCache(); _device = device; @@ -158,12 +159,12 @@ VolumeEntry::VolumeEntry(const char *name, ProFUSE::BlockDevice *device) device->zeroBlock(i); } - void *vp = _blockCache->lock(2); + void *vp = _cache->load(2); IOBuffer b(vp, 0x1a); - write(&b); + writeDirectoryEntry(&b); - _blockCache->unlock(2, true); + _cache->unload(2, true); } @@ -302,7 +303,7 @@ void VolumeEntry::writeDirectoryEntry(IOBuffer *b) b->writeBytes(_fileName, 7); b->write16(_fileCount); b->write16(_accessTime); - b->write16((unsigned)_lastBoot); + b->write16(_lastBoot); // rest is reserved. b->writeZero(4); @@ -338,9 +339,9 @@ FileEntry::FileEntry(const char *name, unsigned fileKind) unsigned length = ValidName(name); if (!length) - throw Exception(__METHOD__ ": Invalid file name."); + throw ProFUSE::Exception(__METHOD__ ": Invalid file name."); - _fileKind = kind; + _fileKind = fileKind; _status = 0; _fileNameLength = length; diff --git a/pascal/File.h b/pascal/File.h index 453126f..4464f2c 100644 --- a/pascal/File.h +++ b/pascal/File.h @@ -53,7 +53,7 @@ public: protected: - unsigned static ValidName(const char *name, unsigned maxSize); + static unsigned ValidName(const char *name, unsigned maxSize); virtual void writeDirectoryEntry(LittleEndian::IOBuffer *); @@ -104,7 +104,7 @@ public: void writeBlock(unsigned block, void *); - static ValidName(const char *); + unsigned static ValidName(const char *); protected: virtual void writeDirectoryEntry(LittleEndian::IOBuffer *); @@ -146,7 +146,7 @@ class FileEntry : public Entry { const char *name() const { return _fileName; } Date modification() const { return _modification; } - static ValidName(const char *); + unsigned static ValidName(const char *); protected: diff --git a/pascal/IOBuffer.h b/pascal/IOBuffer.h index 842a65b..ea3991e 100644 --- a/pascal/IOBuffer.h +++ b/pascal/IOBuffer.h @@ -3,6 +3,7 @@ #include "../Endian.h" +#include namespace LittleEndian { class IOBuffer { @@ -37,7 +38,7 @@ namespace LittleEndian { _offset += 4; } - void writeBytes(const void *value, unsigned count); + void writeBytes(const void *value, unsigned count) { std::memcpy(_offset + (uint8_t *)_buffer, value, count); _size += count; @@ -56,7 +57,7 @@ namespace LittleEndian { unsigned offset() const { return _offset; } void setOffset(unsigned offset) { _offset = offset; } - unsinged size() const { return _size; } + unsigned size() const { return _size; } private: void *_buffer;