/// <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); }
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); }
/// <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); }
/// <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); }
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)); }
internal static SqlFile getFile(SQLiteDatabase db, SqlFsLocker fsLocker, FsID id) { SqlFile f = new SqlFile(db, fsLocker, id); return(f); }