mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: LoadDataFile, SetDataPath, plugin/lzma: missing functions implemented
git-svn-id: svn://ultimatepp.org/upp/trunk@7224 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a24c02583d
commit
2aea70c8ea
4 changed files with 42 additions and 1 deletions
|
|
@ -466,12 +466,26 @@ void LaunchWebBrowser(const String& url)
|
|||
|
||||
#endif
|
||||
|
||||
String sDataPath;
|
||||
|
||||
void SetDataPath(const char *path)
|
||||
{
|
||||
sDataPath = path;
|
||||
}
|
||||
|
||||
String GetDataFile(const char *filename)
|
||||
{
|
||||
if(sDataPath.GetCount())
|
||||
return AppendFileName(sDataPath, filename);
|
||||
String s = GetEnv("UPP_MAIN__");
|
||||
return s.GetCount() ? AppendFileName(s, filename) : GetExeDirFile(filename);
|
||||
}
|
||||
|
||||
String LoadDataFile(const char *filename)
|
||||
{
|
||||
return LoadFile(GetDataFile(filename));
|
||||
}
|
||||
|
||||
String GetComputerName()
|
||||
{
|
||||
char temp[256];
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ void ConsoleMainFn_()
|
|||
#endif
|
||||
|
||||
String GetDataFile(const char *filename);
|
||||
String LoadDataFile(const char *filename);
|
||||
void SetDataPath(const char *path);
|
||||
|
||||
void LaunchWebBrowser(const String& url);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,9 +106,20 @@ application was started from `'theide`' `- in that case theide
|
|||
passes a reference to main package directory through environment
|
||||
variable `"UPP`_MAIN`_`_`" and the resulting file is in this
|
||||
directory. When started standalone, the function is equivalent
|
||||
to GetExeDirFile.&]
|
||||
to GetExeDirFile. Alternatively, application can call SetDataPath
|
||||
to define the directory.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:LoadDataFile`(const char`*`): [_^String^ String]_[* LoadDataFile]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 filename])&]
|
||||
[s2;%% Same as LoadFile(GetDataFile([%-*@3 filename])).&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:SetDataPath`(const char`*`): [@(0.0.255) void]_[* SetDataPath]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 path])&]
|
||||
[s2;%% Defines explicit directory to be used with GetDataFile.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:GetComputerName`(`): [_^String^ String]_[* GetComputerName]()&]
|
||||
[s2;%% Returns the name of computer.&]
|
||||
[s3; &]
|
||||
|
|
|
|||
|
|
@ -221,6 +221,20 @@ int64 LZMADecompress(Stream& out, Stream& in, Gate2<int64, int64> progress)
|
|||
return Decode(&lout.s, &lin.s, progress) == SZ_OK && !in.IsError() && !out.IsError() ? lout.len : -1;
|
||||
}
|
||||
|
||||
String LZMADecompress(const void *data, int64 len, Gate2<int64, int64> progress)
|
||||
{
|
||||
StringStream out;
|
||||
MemReadStream in(data, len);
|
||||
if(LZMADecompress(out, in, progress) >= 0)
|
||||
return out;
|
||||
return String::GetVoid();
|
||||
}
|
||||
|
||||
String LZMADecompress(const String& s, Gate2<int64, int64> progress)
|
||||
{
|
||||
return LZMADecompress(~s, s.GetLength(), progress);
|
||||
}
|
||||
|
||||
bool LZMACompressFile(const char *dstfile, const char *srcfile, Gate2<int64, int64> progress, int lvl)
|
||||
{
|
||||
FileIn in(srcfile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue