private void AddToFileCache(string filename, FileCaching fc) { lock (FileCache) { if (FileCache.ContainsKey(filename) == false) { FileCache.Add(filename, fc); } } }
private static FileCaching FillFileCache(String filename) { FileCaching fc = new FileCaching(); fc.MemStream = new MemoryStream(); fc.FileInfo = new FileInformation(); fc.FileInfo.CreationTime = DateTime.Now; fc.FileInfo.LastAccessTime = DateTime.Now; fc.FileInfo.LastWriteTime = DateTime.Now; fc.FileInfo.Length = 0; fc.FileInfo.FileName = filename; return(fc); }
private int AddToFileCache(string filename) { lock (FileCache) { if (FileCache.ContainsKey(filename) == false) { FileCaching fc = FillFileCache(filename); using (SqlConnection conn = new SqlConnection(ConnectionString)) { using (SqlCommand Cmd = new SqlCommand()) { Cmd.CommandText = "GetFileInformation"; Cmd.Parameters.AddWithValue("@filename", filename); Cmd.Parameters.Add("@IsDirectory", SqlDbType.Bit); Cmd.Parameters["@IsDirectory"].Direction = ParameterDirection.Output; Cmd.Parameters.Add("@Length", SqlDbType.BigInt); Cmd.Parameters["@Length"].Direction = ParameterDirection.Output; Cmd.Parameters.Add("@LastAccessTime", SqlDbType.DateTime); Cmd.Parameters["@LastAccessTime"].Direction = ParameterDirection.Output; Cmd.Parameters.Add("@LastWriteTime", SqlDbType.DateTime); Cmd.Parameters["@LastWriteTime"].Direction = ParameterDirection.Output; Cmd.Parameters.Add("@CreationTime", SqlDbType.DateTime); Cmd.Parameters["@CreationTime"].Direction = ParameterDirection.Output; Cmd.CommandType = CommandType.StoredProcedure; Cmd.Connection = conn; conn.Open(); Cmd.ExecuteNonQuery(); if (Cmd.Parameters["@CreationTime"].Value is System.DBNull) { return(-1 * DokanNet.ERROR_FILE_NOT_FOUND); } fc.FileInfo.FileName = filename; fc.FileInfo.Attributes = (Cmd.Parameters["@IsDirectory"].Value.ToString() == "True") ? System.IO.FileAttributes.Directory : System.IO.FileAttributes.Normal; DateTime.TryParse(Cmd.Parameters["@LastAccessTime"].Value.ToString(), out fc.FileInfo.LastAccessTime); DateTime.TryParse(Cmd.Parameters["@LastWriteTime"].Value.ToString(), out fc.FileInfo.LastWriteTime); DateTime.TryParse(Cmd.Parameters["@CreationTime"].Value.ToString(), out fc.FileInfo.CreationTime); fc.FileInfo.Length = Cmd.Parameters["@Length"].Value is System.DBNull ? 0 : (Int64)Cmd.Parameters["@Length"].Value; FileCache.Add(filename, fc); } } } } return(DokanNet.DOKAN_SUCCESS); }
public int MoveFile(string filename, string newname, bool replace, DokanFileInfo info) { using (SqlConnection conn = new SqlConnection(ConnectionString)) { SqlCommand Cmd = new SqlCommand(); Cmd.CommandText = "MoveFile"; Cmd.Parameters.AddWithValue("@filename", filename); Cmd.Parameters.AddWithValue("@newname", newname); Cmd.Parameters.AddWithValue("@replace", replace); Cmd.CommandType = CommandType.StoredProcedure; Cmd.Connection = conn; conn.Open(); Cmd.ExecuteNonQuery(); //TODO:react on error FileCaching fc = FileCache[filename]; FileCache.Remove(filename); FileCache.Remove(newname); } return(DokanNet.DOKAN_SUCCESS); }
private static FileCaching FillFileCache(String filename) { FileCaching fc = new FileCaching(); fc.MemStream = new MemoryStream(); fc.FileInfo = new FileInformation(); fc.FileInfo.CreationTime = DateTime.Now; fc.FileInfo.LastAccessTime = DateTime.Now; fc.FileInfo.LastWriteTime = DateTime.Now; fc.FileInfo.Length = 0; fc.FileInfo.FileName = filename; return fc; }
private void AddToFileCache(string filename, FileCaching fc) { lock (FileCache) { if (FileCache.ContainsKey(filename) == false) { FileCache.Add(filename, fc); } } }