/// <summary> /// Get information about a file. /// </summary> /// <param name="fileName">Name of the file for which information is requested.</param> /// <param name="rDate">A reference parameter into which the file date is stored.</param> /// <param name="rTime">A reference parameter into which the file time is stored.</param> /// <param name="attribs">A reference parameter into which file attributes are stored.</param> /// <param name="err">Error return value.</param> /// <param name="pUserData">User data object.</param> /// <returns>On success, returns a handle to the open file, and the rDate, rTime, and attribs parameters are filled. /// Returns -1 on error.</returns> /// <remarks>The File Compression Interface calls this function to open a file and return information about it.</remarks> protected virtual IntPtr GetOpenInfo( string fileName, // ref short rDate, ref short rTime, ref short attribs, ref int err, IntPtr pUserData) { Trace.WriteLine(string.Format("GetOpenInfo {0}", fileName)); try { // Get file date/time and attributes FileAttributes fattr = File.GetAttributes(fileName); DateTime fdate = File.GetLastWriteTime(fileName); // Convert to format that FCI understands attribs = FCntl.FAttrsFromFileAttributes(fattr); FCntl.DosDateTimeFromDateTime(fdate, ref rDate, ref rTime); // open file and return handle return(CabIO.FileOpen(fileName, FileAccess.Read, FileShare.None, FileMode.Open, ref err)); } catch (Exception ex) { Trace.WriteLine(ex); err = 1; } return((IntPtr)(-1)); }
/// <summary> /// Opens a file. /// </summary> /// <param name="fileName">The path name of the file to be opened.</param> /// <param name="oflag">Open mode flags.</param> /// <param name="pmode">Share mode flags.</param> /// <returns>Returns an IntPtr that references the open file handle. Returns -1 on error.</returns> /// <remarks>The File Decompression Interface (FDI) calls this function to open files.</remarks> protected virtual IntPtr FileOpen(string fileName, int oflag, int pmode) { Trace.WriteLine("FileOpen {0}", fileName); int err = 0; try { return(CabIO.FileOpen(fileName, oflag, pmode, ref err, userData)); } finally { erf.ErrorType = err; } }
/// <summary> /// Opens a file. /// </summary> /// <param name="fileName">The path name of the file to be opened.</param> /// <param name="oflag">Open mode flags.</param> /// <param name="pmode">Share mode flags.</param> /// <param name="err">Error return value.</param> /// <param name="pUserData">User data object.</param> /// <returns>Returns an IntPtr that references the open file handle. Returns -1 on error.</returns> /// <remarks>The File Compression Interface (FCI) calls this function to open files.</remarks> protected virtual IntPtr FileOpen(string fileName, int oflag, int pmode, ref int err, IntPtr pUserData) { Trace.WriteLine(string.Format("FileOpen {0}", fileName)); return(CabIO.FileOpen(fileName, oflag, pmode, ref err, ((GCHandle)pUserData).Target)); }