Beispiel #1
0
        internal FileRecordData GetFile(string virtualPath)
        {
            int startIndex = virtualPath.IndexOf('/', 1);

            virtualPath = virtualPath.Substring(startIndex + 1);

            string[] parts = virtualPath.Split('/');

            int currentID = _rootID;

            FileRecordData frd = null;

            foreach (string part in parts)
            {
                frd = GetChildFileRecord(currentID, part);

                if (frd == null)
                {
                    return(null);
                }

                currentID = frd.ID;
            }

            return(frd);
        }
Beispiel #2
0
        public override bool DirectoryExists(string virtualDir)
        {
            // Check if it's a database directory
            FileRecordData frd = _db.GetFile(virtualDir);

            if (frd != null)
            {
                return(frd.IsDirectory);
            }

            return(false);
        }
Beispiel #3
0
        /*
         * public override string GetFileHash(IEnumerable virtualPaths, string cacheHash) {
         *
         *  HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();
         *
         *  foreach (string virtualPath in virtualPaths) {
         *      FileRecordData frd = _db.GetFile(virtualPath);
         *
         *      if (frd != null) {
         *          hashCodeCombiner.AddObject(frd.LastChanged.Ticks);
         *      }
         *  }
         *
         *  return hashCodeCombiner.CombinedHashString;
         * }
         */

        public override bool FileExists(string virtualPath)
        {
            // Check if it's a database file
            FileRecordData frd = _db.GetFile(virtualPath);

            if (frd != null)
            {
                return(!frd.IsDirectory);
            }

            return(false);
            //return Previous.FileExists(virtualPath);
        }
Beispiel #4
0
        public override string GetFileHash(string virtualPath, IEnumerable virtualPathDependencies)
        {
            HashCodeCombiner hashCodeCombiner = new HashCodeCombiner();

            FileRecordData frd = _db.GetFile(virtualPath);

            if (frd != null)
            {
                hashCodeCombiner.AddObject(frd.LastChanged.Ticks);
            }

            return(hashCodeCombiner.CombinedHashString);
        }
Beispiel #5
0
        internal FileRecordData GetRecordData(IDataRecord record)
        {
            FileRecordData frd = new FileRecordData();

            frd.ID          = (int)record["ID"];
            frd.ParentID    = (int)record["ParentID"];
            frd.IsDirectory = (bool)record["IsDirectory"];
            frd.Name        = record["Name"] as String;
            frd.Content     = record["Content"] as String;
            frd.LastChanged = (DateTime)record["LastChanged"];

            return(frd);
        }
Beispiel #6
0
        public override VirtualDirectory GetDirectory(string virtualDir)
        {
            FileRecordData frd = _db.GetFile(virtualDir);

            if (frd != null)
            {
                if (!frd.IsDirectory)
                {
                    return(null);
                }

                return(new DbVirtualDirectory(_db, virtualDir, frd));
            }

            return(Previous.GetDirectory(virtualDir));
        }
Beispiel #7
0
        public override VirtualFile GetFile(string virtualPath)
        {
            FileRecordData frd = _db.GetFile(virtualPath);

            if (frd != null)
            {
                if (frd.IsDirectory)
                {
                    return(null);
                }

                return(new DbVirtualFile(virtualPath, frd));
            }

            return(null);
        }
Beispiel #8
0
        bool IEnumerator.MoveNext()
        {
            for (; ;)
            {
                // No more data: we're done
                if (!_dataReader.Read())
                {
                    return(false);
                }

                _childRecord = _dbVirtualDir.Db.GetRecordData(_dataReader);

                // If it's the wrong entry type, ignore it
                if (_childRecord.IsDirectory && _requestedEntryType == RequestedEntryType.Files ||
                    !_childRecord.IsDirectory && _requestedEntryType == RequestedEntryType.Directories)
                {
                    continue;
                }

                // We found a usable child
                return(true);
            }
        }
Beispiel #9
0
        bool IEnumerator.MoveNext()
        {
            for (; ; )
            {

                // No more data: we're done
                if (!_dataReader.Read())
                    return false;

                _childRecord = _dbVirtualDir.Db.GetRecordData(_dataReader);

                // If it's the wrong entry type, ignore it
                if (_childRecord.IsDirectory && _requestedEntryType == RequestedEntryType.Files ||
                    !_childRecord.IsDirectory && _requestedEntryType == RequestedEntryType.Directories)
                {
                    continue;
                }

                // We found a usable child
                return true;
            }
        }
Beispiel #10
0
 public DbVirtualFile(string virtualPath, FileRecordData frd)
     : base(virtualPath)
 {
     _frd = frd;
 }
Beispiel #11
0
 public DbVirtualDirectory(DbAccessLayer db, string virtualPath, FileRecordData frd)
     : base(virtualPath)
 {
     _db = db;
     _frd = frd;
 }
Beispiel #12
0
        internal FileRecordData GetRecordData(IDataRecord record)
        {
            FileRecordData frd = new FileRecordData();
            frd.ID = (int)record["ID"];
            frd.ParentID = (int)record["ParentID"];
            frd.IsDirectory = (bool)record["IsDirectory"];
            frd.Name = record["Name"] as String;
            frd.Content = record["Content"] as String;
            frd.LastChanged = (DateTime)record["LastChanged"];

            return frd;
        }
Beispiel #13
0
 public DbVirtualDirectory(DbAccessLayer db, string virtualPath, FileRecordData frd) : base(virtualPath)
 {
     _db  = db;
     _frd = frd;
 }
Beispiel #14
0
 public DbVirtualFile(string virtualPath, FileRecordData frd) : base(virtualPath)
 {
     _frd = frd;
 }