git-svn-id: https://profuse.googlecode.com/svn/branches/v2@291 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
7cb873bfcf
commit
525fe7810a
|
@ -339,6 +339,7 @@ unsigned VolumeEntry::unlink(const char *name)
|
|||
}
|
||||
|
||||
|
||||
// TODO -- if newName exists, atomically remove it.
|
||||
unsigned VolumeEntry::rename(const char *oldName, const char *newName)
|
||||
{
|
||||
FileEntry *e;
|
||||
|
@ -561,6 +562,42 @@ unsigned VolumeEntry::krunch()
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* return the number of free blocks.
|
||||
* if krunched is true, returns sum of all free blocks
|
||||
* if krunched is false, returns free blocks at end.
|
||||
*
|
||||
*/
|
||||
unsigned VolumeEntry::freeBlocks(bool krunched) const
|
||||
{
|
||||
unsigned freeBlocks = 0;
|
||||
unsigned lastBlock = 0;
|
||||
|
||||
if (krunched)
|
||||
{
|
||||
std::vector<FileEntry *>::const_iterator iter;
|
||||
|
||||
lastBlock = _lastBlock;
|
||||
|
||||
for (iter = _files.begin(); iter != _files.end(); ++iter)
|
||||
{
|
||||
const FileEntry *e = *iter;
|
||||
freeBlocks += e->_firstBlock - lastBlock;
|
||||
lastBlock = e->_lastBlock;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastBlock = _fileCount ? _files.back()->_lastBlock : _lastBlock;
|
||||
}
|
||||
|
||||
|
||||
freeBlocks += _lastVolumeBlock - lastBlock;
|
||||
return freeBlocks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void *VolumeEntry::loadBlock(unsigned block)
|
||||
|
|
|
@ -31,12 +31,12 @@ namespace Pascal {
|
|||
|
||||
Pascal::Date lastBoot() const { return _lastBoot; }
|
||||
|
||||
unsigned freeBlocks(bool krunched = false) const;
|
||||
|
||||
|
||||
FileEntry *fileAtIndex(unsigned i) const;
|
||||
FileEntry *fileByName(const char *name) const;
|
||||
|
||||
void addChild(FileEntry *child, unsigned blocks);
|
||||
|
||||
|
||||
|
||||
void *loadBlock(unsigned block);
|
||||
void unloadBlock(unsigned block, bool dirty = false);
|
||||
|
@ -50,11 +50,11 @@ namespace Pascal {
|
|||
|
||||
unsigned unlink(const char *name);
|
||||
unsigned rename(const char *oldName, const char *newName);
|
||||
|
||||
|
||||
FileEntry *create(const char *name, unsigned blocks);
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned krunch();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue