Example #1
0
		public void writeArchiveFile2File(UnArchiveParam pUnArchiveParam)
		{
			FileStream fileHandle;

			try
			{
				fileHandle = new FileStream(pUnArchiveParam.getUnArchiveFilePath(), FileMode.Open);
			}
			catch(Exception error)
			{
				return;
			}

			if (fileHandle != null)
			{
				readArchiveFileHeader(fileHandle);

				// 写入头部
				foreach (FileHeader item in m_pFileVec)
				{
					item.writeArchiveFile2File(fileHandle, pUnArchiveParam);
				}

				fileHandle.Close ();
			}
		}
Example #2
0
        public void writeArchiveFile2File(UnArchiveParam pUnArchiveParam)
        {
            FileStream fileHandle;

            try
            {
                fileHandle = new FileStream(pUnArchiveParam.getUnArchiveFilePath(), FileMode.Open);
            }
            catch (Exception error)
            {
                return;
            }

            if (fileHandle != null)
            {
                readArchiveFileHeader(fileHandle);

                // 写入头部
                foreach (FileHeader item in m_pFileVec)
                {
                    item.writeArchiveFile2File(fileHandle, pUnArchiveParam);
                }

                fileHandle.Close();
            }
        }
Example #3
0
		public MainWindow () : base (Gtk.WindowType.Toplevel)
		{
			Build ();

			ArchiveData pArchiveData = new ArchiveData ();
			UnArchiveParam pUnArchiveParam = new UnArchiveParam ();
			string path = "E:\\aaaaa\\新建文件夹_0.abc";
			pUnArchiveParam.setUnArchiveFilePath (path);
			pUnArchiveParam.setUnArchiveOutDir (Util.getFullPathNoExtName (path));
			pArchiveData.unArchiveFile (pUnArchiveParam);
		}
Example #4
0
        public MainWindow() : base(Gtk.WindowType.Toplevel)
        {
            Build();

            ArchiveData    pArchiveData    = new ArchiveData();
            UnArchiveParam pUnArchiveParam = new UnArchiveParam();
            string         path            = "E:\\aaaaa\\新建文件夹_0.abc";

            pUnArchiveParam.setUnArchiveFilePath(path);
            pUnArchiveParam.setUnArchiveOutDir(Util.getFullPathNoExtName(path));
            pArchiveData.unArchiveFile(pUnArchiveParam);
        }
Example #5
0
        public void writeArchiveFile2File(FileStream fileHandle, UnArchiveParam pUnArchiveParam)
        {
            m_pFullPath = pUnArchiveParam.getUnArchiveOutDir() + "/" + m_fileNamePath;

            string strPath = Util.getFullPathNoFileName(m_pFullPath);

            Util.mkDir(strPath);                             // 创建目录

            fileHandle.Seek(m_fileOffset, SeekOrigin.Begin); // 移动到文件开始位置

            FileStream localFile;

            try
            {
                localFile = new FileStream(m_pFullPath, FileMode.Create);
            }
            catch (Exception error)
            {
                return;
            }

            byte[] pchar;

            if (localFile != null)
            {
                // 一次性读取进来,可能需要压缩
                pchar = new byte[m_fileSize];

                uint readlength = (uint)fileHandle.Read(pchar, 0, (int)m_fileSize);
                if (readlength == m_fileSize)
                {
                    //if (!FileArchiveToolSys.g_pFileArchiveToolSys.getConfigPtr().bCompress())		// 如果不压缩
                    if (!Util.checkFlags(FileHeaderFlag.eFHF_CPS, ref m_flags))
                    {
                        localFile.Write(pchar, 0, (int)m_fileSize);
                    }
                    else                        // 需要解压
                    {
                        byte[] retChar = null;
                        MLzma.DecompressStrLZMA(pchar, m_fileSize, ref retChar, ref m_fileSize);
                        localFile.Write(retChar, 0, (int)m_fileSize);
                    }
                }
                else                                                                    // 读取可能有问题,读取不了完整文件
                {
                }

                localFile.Close();
            }
        }
Example #6
0
		public void writeArchiveFile2File(FileStream fileHandle, UnArchiveParam pUnArchiveParam)
		{
			m_pFullPath = pUnArchiveParam.getUnArchiveOutDir() + "/" + m_fileNamePath;

			string strPath = Util.getFullPathNoFileName(m_pFullPath);
			Util.mkDir(strPath);		// 创建目录

			fileHandle.Seek(m_fileOffset, SeekOrigin.Begin);	// 移动到文件开始位置

			FileStream localFile;
			try
			{
				localFile = new FileStream(m_pFullPath, FileMode.Create);
			}
			catch(Exception error)
			{
				return;
			}

			byte[] pchar;

			if (localFile != null)
			{
				// 一次性读取进来,可能需要压缩
				pchar = new byte[m_fileSize];

				uint readlength = (uint)fileHandle.Read(pchar, 0, (int)m_fileSize);
				if (readlength == m_fileSize)
				{
					//if (!FileArchiveToolSys.g_pFileArchiveToolSys.getConfigPtr().bCompress())		// 如果不压缩
					if(!Util.checkFlags(FileHeaderFlag.eFHF_CPS, ref m_flags))
					{
						localFile.Write(pchar, 0, (int)m_fileSize);
					}
					else	// 需要解压
					{
						byte[] retChar = null;
						MLzma.DecompressStrLZMA(pchar, m_fileSize, ref retChar, ref m_fileSize);
						localFile.Write(retChar, 0, (int)m_fileSize);
					}
				}
				else							// 读取可能有问题,读取不了完整文件
				{

				}

				localFile.Close();
			}
		}
Example #7
0
		public void unArchiveFile(UnArchiveParam pUnArchiveParam)
		{
			clearFileVec();
			writeArchiveFile2File(pUnArchiveParam);
		}
Example #8
0
 public void unArchiveFile(UnArchiveParam pUnArchiveParam)
 {
     clearFileVec();
     writeArchiveFile2File(pUnArchiveParam);
 }