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);
        }
Ejemplo n.º 2
0
        public virtual SqlFile addFile(string fileName)
        {
            SqlFsErrCode.CurrentError = FsErr.OK;

            SqlFile newFile = null;

            fsLocker.FsLock;
            SqlFsTransaction fsTran = new SqlFsTransaction(db);

            try
            {
                newFile = __addFile(fileName);
                if (newFile != null)
                {
                    fsTran.fsOpSuccess();
                }
            }
            finally
            {
                fsTran.dispose();
                fsLocker.dispose();
            }

            return(newFile);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  Get a fsNode from the result
        /// </summary>
        internal static SqlFsNode getFsNode(SQLiteDatabase db, SqlFsLocker fsLocker, Cursor c)
        {
            SqlFsNode fsNode = null;

            SqlFsConst.FSTYPE type = SqlFsConst.FSTYPE.toFSTYPE(c.getInt(SqlFs.FSBLOCK.fsType.ordinal()));

            if (type == SqlFsConst.FSTYPE.DIR)
            {
                fsNode = SqlDir.getDir(db, fsLocker, c);
            }
            else if (type == SqlFsConst.FSTYPE.FILE)
            {
                fsNode = SqlFile.getFile(db, fsLocker, c);
            }

            return(fsNode);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///  Get list of files only
        /// </summary>
        private List <SqlFile> __getFiles()
        {
            List <SqlFile> fileList = null;
            Cursor         c        = getEntryByName(null, SqlFsConst.FSTYPE.FILE);

            if (c != null)
            {
                c.moveToFirst();
                fileList = new List <SqlFile>(c.Count);
                do
                {
                    SqlFile f = SqlFile.getFile(db, fsLocker, c);
                    if (f != null)
                    {
                        fileList.Add(f);
                    }
                } while (c.moveToNext());
                c.close();
            }

            return(fileList);
        }
Ejemplo n.º 5
0
        internal static SqlFile getFile(SQLiteDatabase db, SqlFsLocker fsLocker, Cursor c)
        {
            FsID id = SqlFsFunc.getID(c, SqlFs.FSBLOCK.fsID.ordinal());

            return(SqlFile.getFile(db, fsLocker, id));
        }
Ejemplo n.º 6
0
        internal static SqlFile getFile(SQLiteDatabase db, SqlFsLocker fsLocker, FsID id)
        {
            SqlFile f = new SqlFile(db, fsLocker, id);

            return(f);
        }