public ArrayStorage(string fullPath) { this.fullPath = fullPath; locker = new ValueLock(); cacheByte = new DictionarySafe <long, byte[]>(); cacheString = new DictionarySafe <long, string>(); var inf = new FileInfo(fullPath); poolReaders = new Pool <FileStream>(); poolWriters = new Pool <FileStream>(); vars = new AsVars(fullPath + ".var"); list = new ArrayStorageList(fullPath + ".asl"); if (!inf.Exists) { if (!inf.Directory.Exists) { inf.Directory.Create(); } inf.Create().Close(); // Выставляем первоначальный размер, что бы не дупустить запись по 0 адресу vars.Length = 10; } if (inf.IsReadOnly) { inf.IsReadOnly = false; } }
public ArrayStorage(string fullPath) { this.fullPath = fullPath; var inf = new FileInfo(fullPath); poolReaders = new Pool <FileStream>(); poolWriters = new Pool <FileStream>(); Key = fullPath.CalculateHashString(); // Создаем заголовок файла. if (!inf.Exists) { //fullPath.CheckPath(); fs = new FileStream(fullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); fs.SetLength(HeaderSize); InitFile(); header_ptr[0] = (long)HeaderSize; } else if (inf.Length < HeaderSize) { throw new Exception("File corrupt."); } else { fs = new FileStream(fullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); // InitFile(); } if (inf.IsReadOnly) { inf.IsReadOnly = false; } list = new ArrayStorageList(fullPath + ".asl"); deleted = new Int64Stack(fullPath + ".del"); free = new Int64Stack(fullPath + ".fre"); }