⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u_filestreamcapture.pas

📁 linux program to read packet data
💻 PAS
字号:
(*
 * One Way Network Sniffer (OWNS)
 * Copyright (C) 2001-2002 OWNS
 *
 * http://owns.sourceforge.net/
 * http://www.owns.st
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *)

(*
 * $Id: u_FileStreamCapture.pas,v 1.3 2002/11/02 14:05:37 owns Exp $
 * Replace TFileStream.
 * Handles statistics for all files created
 *)
unit u_FileStreamCapture;
interface
uses classes,Sysutils,u_Statistics, u_Utils;

type
 TFileStreamCapture = class
 private
   FFileStream : TFileStream;
   FFilePath   : String;
 public
   constructor create(p_FilePath : String);
   destructor destroy; override;
   function Write(const Buffer; Count: Longint): Longint;
 end;

implementation

constructor TFileStreamCapture.create(p_FilePath : String);
var
  i : Integer;
begin
  FFilePath := convertPath(p_FilePath); // this way, path can have '/' or '\' without problem
  ForceDirectories(ExtractFilePath(FFilePath));
  FFileStream := TFileStream.create(FFilePath,fmCreate);
  g_Statistics.currentFilePath := FFilePath;
  g_Statistics.NbFilescreated := g_Statistics.NbFilescreated+1;
end;

function TFileStreamCapture.Write(const Buffer; Count: Longint): Longint;
begin
  result := FFileStream.write(Buffer,Count);
  g_Statistics.BytesSaved := g_Statistics.BytesSaved+result;
end;

destructor TFileStreamCapture.destroy;
begin
  if FFileStream <> nil then FFileStream.free;
  inherited;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -