5 bool hash(LPCTSTR fn
, filehash
& fh
)
9 if(!f
.Open(fn
, CFile::modeRead
|CFile::osSequentialScan
|CFile::shareDenyNone
, &fe
))
16 fh
.size
= f
.GetLength();
19 for(UINT64 tmp
= 0, i
= 0; i
< 65536/sizeof(tmp
) && f
.Read(&tmp
, sizeof(tmp
)); fh
.hash
+= tmp
, i
++);
20 f
.Seek(max(0, (INT64
)fh
.size
- 65536), CFile::begin
);
21 for(UINT64 tmp
= 0, i
= 0; i
< 65536/sizeof(tmp
) && f
.Read(&tmp
, sizeof(tmp
)); fh
.hash
+= tmp
, i
++);
26 void hash(CPlaylist
& pl
, CList
<filehash
>& fhs
)
30 POSITION pos
= pl
.GetHeadPosition();
33 CString fn
= pl
.GetNext(pos
).m_fns
.GetHead();
34 if(AfxGetAppSettings().Formats
.FindExt(CPath(fn
).GetExtension().MakeLower(), true))
45 CStringA
makeargs(CPlaylist
& pl
)
50 CAtlList
<CStringA
> args
;
52 POSITION pos
= fhs
.GetHeadPosition();
53 for(int i
= 0; pos
; i
++)
55 filehash
& fh
= fhs
.GetNext(pos
);
58 str
.Format("name[%d]=%s&size[%d]=%016I64x&hash[%d]=%016I64x",
59 i
, UrlEncode(CStringA(fh
.name
)),
66 return Implode(args
, '&');
69 bool OpenUrl(CInternetSession
& is
, CString url
, CStringA
& str
)
75 CAutoPtr
<CStdioFile
> f(is
.OpenURL(url
, 1, INTERNET_FLAG_TRANSFER_BINARY
|INTERNET_FLAG_EXISTING_CONNECT
));
78 for(int len
; (len
= f
->Read(buff
, sizeof(buff
))) > 0; str
+= CStringA(buff
, len
));
80 f
->Close(); // must close it because the desctructor doesn't seem to do it and we will get an exception when "is" is destroying
82 catch(CInternetException
* ie
)