public int FlushFileBuffers(int midx, String filename, DokanFileInfo info) { CFile ix = get_cfile_internal(midx, filename); if (ix == null) { return(-DokanNet.ERROR_PATH_NOT_FOUND); } ix.open_file(false); ix.sync(); ix.set_dokanio_flag2(false); REDDY.FSIDList[midx].set_dirty(true); return(0); }
/* * This file dups itself into another file, the old version is not deleted. * More like a new reincarnate without loosing old data. The responsibility * of updating path/name is left to CDirectory, as there are only incore data * from the POV of CFile. */ public CFile dup_file(int newfsid, int inode, int pino, string newpath) { if (m_state == FILE_STATE.FILE_DELETED) { return(null); } open_file(false); /* * It is okay to not lock cfnew since nobody actually know that this is * on the system. As nobody else touch this, we can do without locks for the new file. */ lock (this) { if (_mywip == null) { DEFS.ASSERT(m_state == FILE_STATE.FILE_DELETED, "Should be marked deleted, or else some workflow issue"); return(null); } REDDY.ptrRedFS.sync(_mywip); REDDY.ptrRedFS.flush_cache(_mywip, true); //should we write the source inodefile to disk also? CFile cfnew = new CFile(newfsid, inode, pino, m_name, newpath); cfnew.open_file(true); REDDY.ptrRedFS.redfs_dup_file(_mywip, cfnew._mywip); cfnew.m_atime = m_atime; cfnew.m_ctime = m_ctime; cfnew.m_mtime = m_mtime; cfnew.m_size = _mywip.get_filesize(); cfnew.set_ibflag(_mywip.get_ibflag()); cfnew.touch(); //int numblocks = OPS.FSIZETONUMBLOCKS(m_clist[i].get_size()); int numblocks = OPS.NUML0(m_size) + OPS.NUML1(m_size) + OPS.NUML2(m_size); REDDY.FSIDList[newfsid].diff_upadate_logical_data(numblocks * 4096); //not the correct figure per-se REDDY.FSIDList[newfsid].set_dirty(true); DEFS.DEBUGYELLOW("INCRCNT", "Grew fsid usage by " + numblocks + " (file)"); cfnew.sync(); return(cfnew); } }