Ejemplo n.º 1
0
        /// <summary>
        ///  Add a new entry for file. File must be saved so as to be
        ///  appeared under its parent directory.
        /// </summary>
        private SqlFile __addFile(string fileName)
        {
            if ((fileName = checkInvalidChars(fileName)) == null)
            {
                SqlFsErrCode.CurrentError = FsErr.InvalidChars;
                return(null);
            }

            if (__isAlreadyExist(fileName))
            {
                SqlFsErrCode.CurrentError = FsErr.NameAlreadyExists;
                return(null);
            }

            FsID newID = SqlFile.addFile(db, fileName, this.ID);

            if (newID.compare(SqlFsConst.INVALIDID) <= 0)
            {
                SqlFsErrCode.CurrentError = FsErr.NoNewIDForNewFsNode;
                return(null);
            }

            if (!updateChildList(SqlFsConst.FSOP.ADD, newID, FsID.toFsID(0)))
            {
                // delete entry just created
                SqlFs.deleteEntryByID(db, SqlFs.DBNAMES.FsBlock.ToString(), SqlFs.FSBLOCK.fsID.ToString(), newID);
                return(null);
            }

            SqlFile f = SqlFile.getFile(db, fsLocker, newID);

            f.setDataBlockID(SqlFsConst.NOFILEDATAID);
            return(f);
        }