summaryrefslogtreecommitdiff
path: root/plugins/Watrack/i_cover.inc
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-10-08 18:43:29 +0000
commit864081102a5f252415f41950b3039a896b4ae9c5 (patch)
treec6b764651e9dd1f8f53b98eab05f16ba4a492a79 /plugins/Watrack/i_cover.inc
parentdb5149b48346c417e18add5702a9dfe7f6e28dd0 (diff)
Awkwars's plugins - welcome to our trunk
git-svn-id: http://svn.miranda-ng.org/main/trunk@1822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Watrack/i_cover.inc')
-rw-r--r--plugins/Watrack/i_cover.inc90
1 files changed, 90 insertions, 0 deletions
diff --git a/plugins/Watrack/i_cover.inc b/plugins/Watrack/i_cover.inc
new file mode 100644
index 0000000000..48f515882a
--- /dev/null
+++ b/plugins/Watrack/i_cover.inc
@@ -0,0 +1,90 @@
+{any utils}
+function GetCover(var dst:pWideChar;mfile:pWideChar):boolean;
+var
+ line,line1:array [0..511] of WideChar;
+ p,p1:PWideChar;
+ i:integer;
+ fdata:WIN32_FIND_DATAW;
+ hTmp:THANDLE;
+ wr,wr1:pWideChar;
+begin
+ result:=false;
+ dst:=nil;
+ if (CoverPaths=nil) or (CoverPaths^=#0) then exit;
+ p:=CoverPaths;
+ repeat
+ p1:=p;
+ while p^>=' ' do inc(p);
+ i:=p-p1;
+ if i>0 then
+ begin
+ move(p1^,line,i*SizeOf(WideChar));
+ line[i]:=#0;
+ if ServiceExists(MS_WAT_REPLACETEXT)<>0 then
+ wr:=pWideChar(CallService(MS_WAT_REPLACETEXT,0,lparam(@line)))
+ else
+ wr:=@line;
+
+ if isPathAbsolute(wr) then
+ begin
+ hTmp:=FindFirstFileW(wr,fdata);
+ end
+ else
+ begin
+ wr1:=ExtractW(mfile,false);
+ StrCopyW(line,wr1);
+ mFreeMem(wr1);
+ StrCatW(line,wr);
+ hTmp:=FindFirstFileW(line,fdata);
+ end;
+ if dword(hTmp)<>INVALID_HANDLE_VALUE then
+ begin
+ wr1:=ExtractW(line,false);
+ StrCopyW(line1,wr1);
+ mFreeMem(wr1);
+ StrCatW(line1,pWideChar(@fdata.cFileName));
+
+ GetFullPathNameW(line1,SizeOf(line) div SizeOf(WideChar),line,wr1);
+ StrDupW(dst,line);
+ result:=true;
+ FindClose(hTmp); //!!
+ end;
+ if wr<>@line then mFreeMem(wr);
+ if result then break;
+ end;
+ while p^<' ' do
+ begin
+ if p^=#0 then break;
+ inc(p);
+ end;
+ until p^=#0;
+end;
+
+function GetLyric(var dst:pWideChar;mfile:pWideChar):boolean;
+var
+ buf:array [0..511] of WideChar;
+ f:THANDLE;
+ size:integer;
+ tmp:PAnsiChar;
+begin
+ StrCopyW(buf,mfile);
+ ChangeExtW(buf,'txt');
+ f:=Reset(buf);
+ if f=THANDLE(INVALID_HANDLE_VALUE) then
+ begin
+ dst:=nil;
+ result:=false;
+ exit;
+ end;
+ size:=FileSize(f);
+ if size>0 then
+ begin
+ mGetMem(tmp,size+1);
+ BlockRead(f,tmp^,size);
+ tmp[size]:=#0;
+ AnsiToWide(tmp,dst);
+ mFreeMem(tmp);
+ end;
+ CloseHandle(f);
+ result:=true;
+end;