singrdk/base/Services/Fat/Fs/FileCache.sg

42 lines
1.2 KiB
Plaintext
Raw Normal View History

2008-03-05 09:52:00 -05:00
///////////////////////////////////////////////////////////////////////////////
//
// Microsoft Research Singularity
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: FileCache.sg
//
// Note:
//
// This cache is for recently closed files. Opened
// files are not stored here. This cache exists because
// opening a file entails a non-trivial amount of work.
//
// File metadata does not have a fixed size and this cache
// should probably take this into account.
namespace Microsoft.Singularity.Services.Fat.Fs
{
internal class FileCache
{
FsObjectCache! cache;
internal FileCache(uint capacity)
{
this.cache = new FsObjectCache(capacity);
}
internal void Add(int firstCluster, File! directory)
2008-11-17 18:29:00 -05:00
requires firstCluster != 0; // 0-byte files have inval firstCluster
2008-03-05 09:52:00 -05:00
{
cache.Add(firstCluster, directory);
}
internal File Get(int firstCluster)
2008-11-17 18:29:00 -05:00
requires firstCluster != 0; // 0-byte files have inval firstCluster
2008-03-05 09:52:00 -05:00
{
return (File)cache.Get(firstCluster);
}
}
}