From 864081102a5f252415f41950b3039a896b4ae9c5 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 8 Oct 2012 18:43:29 +0000 Subject: Awkwars's plugins - welcome to our trunk git-svn-id: http://svn.miranda-ng.org/main/trunk@1822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Utils.pas/utils.pas | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 plugins/Utils.pas/utils.pas (limited to 'plugins/Utils.pas/utils.pas') diff --git a/plugins/Utils.pas/utils.pas b/plugins/Utils.pas/utils.pas new file mode 100644 index 0000000000..8c16e03f81 --- /dev/null +++ b/plugins/Utils.pas/utils.pas @@ -0,0 +1,44 @@ +unit Utils; + +interface + +uses windows; + +function SaveTemporaryW(ptr:pointer;size:dword;ext:PWideChar=nil):pWideChar; +function SaveTemporary (ptr:pointer;size:dword;ext:PAnsiChar=nil):PAnsiChar; + +implementation + +uses common,io; + +function SaveTemporaryW(ptr:pointer;size:dword;ext:PWideChar=nil):pWideChar; +var + buf,buf1:array [0..MAX_PATH-1] of WideChar; + f:THANDLE; +begin + GetTempPathW(MAX_PATH,buf); + GetTempFileNameW(buf,'wat',GetCurrentTime,buf1); + ChangeExtW(buf1,ext); + + f:=ReWrite(buf1); + BlockWrite(f,pByte(ptr)^,size); + CloseHandle(f); + StrDupW(result,buf1); +end; + +function SaveTemporary(ptr:pointer;size:dword;ext:PAnsiChar=nil):PAnsiChar; +var + buf,buf1:array [0..MAX_PATH-1] of AnsiChar; + f:THANDLE; +begin + GetTempPathA(SizeOf(buf),buf); + GetTempFileNameA(buf,'wat',GetCurrentTime,buf1); + ChangeExt(buf1,ext); + + f:=ReWrite(buf1); + BlockWrite(f,pByte(ptr)^,size); + CloseHandle(f); + StrDup(result,buf1); +end; + +end. \ No newline at end of file -- cgit v1.2.3