mirror of
https://github.com/ksherlock/profuse.git
synced 2025-01-12 20:29:44 +00:00
git-svn-id: https://profuse.googlecode.com/svn/branches/v2@151 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
72a5a28745
commit
147a16085a
@ -1,11 +1,11 @@
|
|||||||
#include "DateRec.h"
|
#include "Date.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace Pascal;
|
using namespace Pascal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DateRec::DateRec(unsigned val)
|
Date::Date(unsigned val)
|
||||||
{
|
{
|
||||||
// yyyy yyym mmmm dddd
|
// yyyy yyym mmmm dddd
|
||||||
_month = val & 0xf;
|
_month = val & 0xf;
|
||||||
@ -13,7 +13,7 @@ DateRec::DateRec(unsigned val)
|
|||||||
_year = (val >> 9) & 0x7f;
|
_year = (val >> 9) & 0x7f;
|
||||||
}
|
}
|
||||||
|
|
||||||
DateRec::operator std::time_t() const {
|
Date::operator std::time_t() const {
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
if (_day == 0 || _month == 0) return (std::time_t)-1;
|
if (_day == 0 || _month == 0) return (std::time_t)-1;
|
||||||
@ -27,3 +27,18 @@ DateRec::operator std::time_t() const {
|
|||||||
|
|
||||||
return std::mktime(&tm);
|
return std::mktime(&tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Date::operator unsigned() const {
|
||||||
|
// year must be 0 .. 127
|
||||||
|
return (_year << 9) | (_day << 4) | _month;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date Date::Today()
|
||||||
|
{
|
||||||
|
struct tm tm;
|
||||||
|
std::time_t t = std::time(NULL);
|
||||||
|
|
||||||
|
::localtime_r(&t, &tm);
|
||||||
|
|
||||||
|
return Date(tm.tm_year, tm.tm_month, tm.tm_mday);
|
||||||
|
}
|
@ -1,18 +1,21 @@
|
|||||||
#ifndef __DATEREC_H__
|
#ifndef __PASCAL_DATE_H__
|
||||||
#define __DATEREC_H__
|
#define __PASCAL_DATE_H__
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
namespace Pascal {
|
namespace Pascal {
|
||||||
|
|
||||||
class DateRec {
|
class Date {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DateRec();
|
static Date Today();
|
||||||
DateRec(unsigned yy, unsigned mm, unsigned dd);
|
|
||||||
DateRec(unsigned);
|
Date();
|
||||||
|
Date(unsigned yy, unsigned mm, unsigned dd);
|
||||||
|
Date(unsigned);
|
||||||
|
|
||||||
operator std::time_t() const;
|
operator std::time_t() const;
|
||||||
|
operator unsigned() const;
|
||||||
|
|
||||||
unsigned month() const { return _month; }
|
unsigned month() const { return _month; }
|
||||||
unsigned day() const { return _day; }
|
unsigned day() const { return _day; }
|
||||||
@ -25,14 +28,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline DateRec::DateRec()
|
inline Date::Date()
|
||||||
{
|
{
|
||||||
_year = 0;
|
_year = 0;
|
||||||
_month = 0;
|
_month = 0;
|
||||||
_day = 0;
|
_day = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline DateRec::DateRec(unsigned yy, unsigned mm, unsigned dd)
|
inline Date::Date(unsigned yy, unsigned mm, unsigned dd)
|
||||||
{
|
{
|
||||||
_year = yy;
|
_year = yy;
|
||||||
_month = mm;
|
_month = mm;
|
||||||
|
@ -152,7 +152,7 @@ void VolumeEntry::init(void *vp)
|
|||||||
_lastVolumeBlock = Read16(vp, 0x0e);
|
_lastVolumeBlock = Read16(vp, 0x0e);
|
||||||
_fileCount = Read16(vp, 0x10);
|
_fileCount = Read16(vp, 0x10);
|
||||||
_accessTime = Read16(vp, 0x12);
|
_accessTime = Read16(vp, 0x12);
|
||||||
_lastBoot = DateRec(Read16(vp, 0x14));
|
_lastBoot = Date(Read16(vp, 0x14));
|
||||||
|
|
||||||
setInode(1);
|
setInode(1);
|
||||||
_inodeGenerator = 1;
|
_inodeGenerator = 1;
|
||||||
@ -196,7 +196,7 @@ FileEntry::FileEntry(void *vp) :
|
|||||||
std::memset(_fileName, 0, 16);
|
std::memset(_fileName, 0, 16);
|
||||||
std::memcpy(_fileName, 0x07 + (uint8_t *)vp, _fileNameLength);
|
std::memcpy(_fileName, 0x07 + (uint8_t *)vp, _fileNameLength);
|
||||||
_lastByte = Read16(vp, 0x16);
|
_lastByte = Read16(vp, 0x16);
|
||||||
_modification = DateRec(Read16(vp, 0x18));
|
_modification = Date(Read16(vp, 0x18));
|
||||||
|
|
||||||
_fileSize = 0;
|
_fileSize = 0;
|
||||||
_pageSize = NULL;
|
_pageSize = NULL;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef __FILE_H__
|
#ifndef __FILE_H__
|
||||||
#define __FILE_H__
|
#define __FILE_H__
|
||||||
|
|
||||||
#include "DateRec.h"
|
#include "Date.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public:
|
|||||||
unsigned fileCount() const { return _fileCount; }
|
unsigned fileCount() const { return _fileCount; }
|
||||||
unsigned volumeBlocks() const { return _lastVolumeBlock; }
|
unsigned volumeBlocks() const { return _lastVolumeBlock; }
|
||||||
|
|
||||||
Pascal::DateRec lastBoot() const { return _lastBoot; }
|
Pascal::Date lastBoot() const { return _lastBoot; }
|
||||||
|
|
||||||
FileEntry *fileAtIndex(unsigned i) const;
|
FileEntry *fileAtIndex(unsigned i) const;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ private:
|
|||||||
unsigned _lastVolumeBlock;
|
unsigned _lastVolumeBlock;
|
||||||
unsigned _fileCount;
|
unsigned _fileCount;
|
||||||
unsigned _accessTime;
|
unsigned _accessTime;
|
||||||
Pascal::DateRec _lastBoot;
|
Pascal::Date _lastBoot;
|
||||||
|
|
||||||
std::vector<FileEntry *> _files;
|
std::vector<FileEntry *> _files;
|
||||||
unsigned _inodeGenerator;
|
unsigned _inodeGenerator;
|
||||||
@ -121,7 +121,7 @@ class FileEntry : public Entry {
|
|||||||
int read(uint8_t *buffer, unsigned size, unsigned offset);
|
int read(uint8_t *buffer, unsigned size, unsigned offset);
|
||||||
|
|
||||||
const char *name() const { return _fileName; }
|
const char *name() const { return _fileName; }
|
||||||
DateRec modification() const { return _modification; }
|
Date modification() const { return _modification; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class FileEntry : public Entry {
|
|||||||
char _fileName[16];
|
char _fileName[16];
|
||||||
|
|
||||||
unsigned _lastByte;
|
unsigned _lastByte;
|
||||||
DateRec _modification;
|
Date _modification;
|
||||||
|
|
||||||
// non-text files
|
// non-text files
|
||||||
unsigned dataFileSize();
|
unsigned dataFileSize();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "DateRec.h"
|
#include "Date.h"
|
||||||
#include "../BlockDevice.h"
|
#include "../BlockDevice.h"
|
||||||
#include "../DiskCopy42Image.h"
|
#include "../DiskCopy42Image.h"
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void printUnusedEntry(unsigned block, unsigned size)
|
|||||||
|
|
||||||
void printFileEntry(Pascal::FileEntry *e, bool extended)
|
void printFileEntry(Pascal::FileEntry *e, bool extended)
|
||||||
{
|
{
|
||||||
Pascal::DateRec dt = e->modification();
|
Pascal::Date dt = e->modification();
|
||||||
|
|
||||||
if (extended)
|
if (extended)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user