mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
remove POCO_WIN32_UTF8
This commit is contained in:
parent
c7c6871c4a
commit
7872c35324
@ -33,7 +33,7 @@
|
||||
#include <sqlucode.h>
|
||||
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#define POCO_ODBC_UNICODE
|
||||
#define POCO_ODBC_UNICODE_WINDOWS
|
||||
#elif defined(POCO_OS_FAMILY_UNIX) && defined(UNICODE)
|
||||
|
@ -29,11 +29,7 @@ FileStreamTest::~FileStreamTest()
|
||||
|
||||
void FileStreamTest::testRead()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file.append(".txt");
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
char tmp[]={'\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file.append(".txt");
|
||||
@ -57,11 +53,7 @@ void FileStreamTest::testRead()
|
||||
|
||||
void FileStreamTest::testWrite()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xdf', '\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + (".txt");
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
char tmp[]={'\xc3', '\x9f', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + ".txt";
|
||||
@ -86,15 +78,9 @@ void FileStreamTest::testWrite()
|
||||
|
||||
void FileStreamTest::testReadWrite()
|
||||
{
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_WIN32_UTF8)
|
||||
char tmp[]={'\xdf', '\xc4', '\xd6', '\xdc', '\xe4', '\xf6', '\xfc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + (".txt");
|
||||
#else
|
||||
char tmp[]={'\xc3', '\x9f', '\xc3', '\x84', '\xc3', '\x96', '\xc3', '\x9c', '\xc3', '\xa4', '\xc3', '\xb6', '\xc3', '\xbc', '\0'};
|
||||
std::string file(tmp);
|
||||
file = "dummy_" + file + ".txt";
|
||||
#endif
|
||||
|
||||
Poco::TemporaryFile::registerForDeletion(file);
|
||||
|
||||
@ -122,9 +108,9 @@ void FileStreamTest::testOpenModeIn()
|
||||
Poco::File f("nonexistent.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
{
|
||||
Poco::FileInputStream istr("nonexistent.txt");
|
||||
fail("nonexistent file - must throw");
|
||||
}
|
||||
@ -143,20 +129,20 @@ void FileStreamTest::testOpenModeOut()
|
||||
Poco::File f("test.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
|
||||
Poco::FileOutputStream ostr1("test.txt");
|
||||
ostr1 << "Hello, world!";
|
||||
ostr1.close();
|
||||
|
||||
assertTrue (f.exists());
|
||||
assertTrue (f.getSize() != 0);
|
||||
|
||||
|
||||
Poco::FileStream str1("test.txt");
|
||||
str1.close();
|
||||
|
||||
assertTrue (f.exists());
|
||||
assertTrue (f.getSize() != 0);
|
||||
|
||||
|
||||
Poco::FileOutputStream ostr2("test.txt");
|
||||
ostr2.close();
|
||||
|
||||
@ -172,14 +158,14 @@ void FileStreamTest::testOpenModeTrunc()
|
||||
Poco::File f("test.txt");
|
||||
if (f.exists())
|
||||
f.remove();
|
||||
|
||||
|
||||
Poco::FileOutputStream ostr1("test.txt");
|
||||
ostr1 << "Hello, world!";
|
||||
ostr1.close();
|
||||
|
||||
assertTrue (f.exists());
|
||||
assertTrue (f.getSize() != 0);
|
||||
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::trunc);
|
||||
str1.close();
|
||||
|
||||
@ -195,16 +181,16 @@ void FileStreamTest::testOpenModeAte()
|
||||
Poco::FileOutputStream ostr("test.txt");
|
||||
ostr << "0123456789";
|
||||
ostr.close();
|
||||
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::ate);
|
||||
int c = str1.get();
|
||||
assertTrue (str1.eof());
|
||||
|
||||
|
||||
str1.clear();
|
||||
str1.seekg(0);
|
||||
c = str1.get();
|
||||
assertTrue (c == '0');
|
||||
|
||||
|
||||
str1.close();
|
||||
|
||||
Poco::FileStream str2("test.txt", std::ios::ate);
|
||||
@ -222,15 +208,15 @@ void FileStreamTest::testOpenModeApp()
|
||||
Poco::FileOutputStream ostr("test.txt");
|
||||
ostr << "0123456789";
|
||||
ostr.close();
|
||||
|
||||
|
||||
Poco::FileStream str1("test.txt", std::ios::app);
|
||||
|
||||
str1 << "abc";
|
||||
|
||||
|
||||
str1.seekp(0);
|
||||
|
||||
|
||||
str1 << "def";
|
||||
|
||||
|
||||
str1.close();
|
||||
|
||||
Poco::FileInputStream istr("test.txt");
|
||||
@ -245,35 +231,35 @@ void FileStreamTest::testSeek()
|
||||
{
|
||||
Poco::FileStream str("test.txt", std::ios::trunc);
|
||||
str << "0123456789abcdef";
|
||||
|
||||
|
||||
str.seekg(0);
|
||||
int c = str.get();
|
||||
assertTrue (c == '0');
|
||||
|
||||
|
||||
str.seekg(10);
|
||||
assertTrue (str.tellg() == std::streampos(10));
|
||||
c = str.get();
|
||||
assertTrue (c == 'a');
|
||||
assertTrue (str.tellg() == std::streampos(11));
|
||||
|
||||
|
||||
str.seekg(-1, std::ios::end);
|
||||
assertTrue (str.tellg() == std::streampos(15));
|
||||
c = str.get();
|
||||
assertTrue (c == 'f');
|
||||
assertTrue (str.tellg() == std::streampos(16));
|
||||
|
||||
|
||||
str.seekg(-1, std::ios::cur);
|
||||
assertTrue (str.tellg() == std::streampos(15));
|
||||
c = str.get();
|
||||
assertTrue (c == 'f');
|
||||
assertTrue (str.tellg() == std::streampos(16));
|
||||
|
||||
|
||||
str.seekg(-4, std::ios::cur);
|
||||
assertTrue (str.tellg() == std::streampos(12));
|
||||
c = str.get();
|
||||
assertTrue (c == 'c');
|
||||
assertTrue (str.tellg() == std::streampos(13));
|
||||
|
||||
|
||||
str.seekg(1, std::ios::cur);
|
||||
assertTrue (str.tellg() == std::streampos(14));
|
||||
c = str.get();
|
||||
@ -289,7 +275,7 @@ void FileStreamTest::testMultiOpen()
|
||||
str << "abcdefghij\n";
|
||||
str << "klmnopqrst\n";
|
||||
str.close();
|
||||
|
||||
|
||||
std::string s;
|
||||
str.open("test.txt", std::ios::in);
|
||||
std::getline(str, s);
|
||||
@ -299,7 +285,7 @@ void FileStreamTest::testMultiOpen()
|
||||
str.open("test.txt", std::ios::in);
|
||||
std::getline(str, s);
|
||||
assertTrue (s == "0123456789");
|
||||
str.close();
|
||||
str.close();
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,7 +380,7 @@ void FileTest::testCopy()
|
||||
f1.setWriteable().remove();
|
||||
}
|
||||
|
||||
void FileTest::testCopyFailIfDestinationFileExists()
|
||||
void FileTest::testCopyFailIfDestinationFileExists()
|
||||
{
|
||||
std::ofstream ostr("testfile.dat");
|
||||
ostr << "Hello, world!" << std::endl;
|
||||
@ -499,7 +499,7 @@ void FileTest::testCopyDirectory()
|
||||
fd3.remove(true);
|
||||
}
|
||||
|
||||
void FileTest::testCopyDirectoryFailIfExists()
|
||||
void FileTest::testCopyDirectoryFailIfExists()
|
||||
{
|
||||
Path pd1("testdir");
|
||||
File fd1(pd1);
|
||||
@ -516,7 +516,7 @@ void FileTest::testCopyDirectoryFailIfExists()
|
||||
std::ofstream ostr2(pf2.toString().c_str());
|
||||
ostr2 << "Hello, world!" << std::endl;
|
||||
ostr2.close();
|
||||
|
||||
|
||||
Path pd2("destination");
|
||||
File fd2(pd2);
|
||||
try {
|
||||
@ -584,7 +584,7 @@ void FileTest::testRenameFailIfExists() {
|
||||
|
||||
void FileTest::testLongPath()
|
||||
{
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8) && !defined(_WIN32_WCE)
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE)
|
||||
Poco::Path p("longpathtest");
|
||||
p.makeAbsolute();
|
||||
std::string longpath(p.toString());
|
||||
@ -601,7 +601,7 @@ void FileTest::testLongPath()
|
||||
assertTrue (d.isDirectory());
|
||||
|
||||
Poco::File f(p.toString());
|
||||
f.remove(true);
|
||||
f.remove(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -17,16 +17,16 @@
|
||||
#include "Poco/Environment.h"
|
||||
#include <iostream>
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8)
|
||||
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if defined(_WIN32_WCE)
|
||||
#include "Poco/Path_WINCE.h"
|
||||
#else
|
||||
#include "Poco/Path_WIN32U.h"
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/Path_WIN32.h"
|
||||
#endif
|
||||
|
||||
|
||||
using Poco::Path;
|
||||
using Poco::PathSyntaxException;
|
||||
using Poco::Environment;
|
||||
@ -98,7 +98,7 @@ void PathTest::testParseUnix1()
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_UNIX) == "usr");
|
||||
|
||||
|
||||
p.parse("/usr/local", Path::PATH_UNIX);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -214,7 +214,7 @@ void PathTest::testParseUnix3()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_UNIX) == "/usr/local/bin/");
|
||||
|
||||
|
||||
p.parse("/usr/local/./bin/", Path::PATH_UNIX);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -345,7 +345,7 @@ void PathTest::testParseUnix4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_UNIX) == "../lib/");
|
||||
|
||||
|
||||
p.parse("a/b/c/d", Path::PATH_UNIX);
|
||||
assertTrue (p.isRelative());
|
||||
assertTrue (!p.isAbsolute());
|
||||
@ -371,7 +371,7 @@ void PathTest::testParseUnix5()
|
||||
assertTrue (p[1] == "system32");
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_UNIX) == "/c:/windows/system32/");
|
||||
assertTrue (p.toString(Path::PATH_UNIX) == "/c:/windows/system32/");
|
||||
}
|
||||
|
||||
|
||||
@ -467,7 +467,7 @@ void PathTest::testParseWindows2()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "usr\\");
|
||||
|
||||
|
||||
p.parse("/usr/local", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -574,7 +574,7 @@ void PathTest::testParseWindows2()
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "\\usr\\local\\bin\\");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PathTest::testParseWindows3()
|
||||
{
|
||||
Path p;
|
||||
@ -739,7 +739,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\server\\files\\");
|
||||
|
||||
|
||||
p.parse("\\\\server\\files\\file", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -770,7 +770,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.getNode() == "server");
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\server\\files\\dir\\file");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\server\\files\\dir\\file");
|
||||
|
||||
p.parse("\\\\server", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
@ -780,7 +780,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "\\\\server\\");
|
||||
|
||||
|
||||
p.parse("c:\\", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -788,7 +788,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.getDevice() == "c");
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\");
|
||||
|
||||
p.parse("c:\\WinNT", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
@ -797,7 +797,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.getDevice() == "c");
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\WinNT");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\WinNT");
|
||||
|
||||
p.parse("c:\\WinNT\\", Path::PATH_WINDOWS);
|
||||
assertTrue (!p.isRelative());
|
||||
@ -808,7 +808,7 @@ void PathTest::testParseWindows4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\WinNT\\");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
p.parse("~:\\", Path::PATH_WINDOWS);
|
||||
@ -817,7 +817,7 @@ void PathTest::testParseWindows4()
|
||||
catch (PathSyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
p.parse("c:file.txt", Path::PATH_WINDOWS);
|
||||
@ -826,7 +826,7 @@ void PathTest::testParseWindows4()
|
||||
catch (PathSyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
p.parse("a\\b\\c\\d", Path::PATH_WINDOWS);
|
||||
assertTrue (p.isRelative());
|
||||
assertTrue (!p.isAbsolute());
|
||||
@ -850,7 +850,7 @@ void PathTest::testParseVMS1()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "");
|
||||
|
||||
|
||||
p.parse("[]", Path::PATH_VMS);
|
||||
assertTrue (p.isRelative());
|
||||
assertTrue (!p.isAbsolute());
|
||||
@ -858,7 +858,7 @@ void PathTest::testParseVMS1()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "");
|
||||
|
||||
|
||||
p.parse("[foo]", Path::PATH_VMS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -896,7 +896,7 @@ void PathTest::testParseVMS1()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "[.foo.bar]");
|
||||
|
||||
|
||||
p.parse("[foo.bar.foobar]", Path::PATH_VMS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -933,7 +933,7 @@ void PathTest::testParseVMS2()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "[foo.bar]");
|
||||
|
||||
|
||||
p.parse("[foo.][bar]", Path::PATH_VMS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -943,7 +943,7 @@ void PathTest::testParseVMS2()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "[foo.bar]");
|
||||
|
||||
|
||||
p.parse("[foo.bar][foo]", Path::PATH_VMS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -954,7 +954,7 @@ void PathTest::testParseVMS2()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "[foo.bar.foo]");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
p.parse("[foo.bar][.foo]", Path::PATH_VMS);
|
||||
@ -972,7 +972,7 @@ void PathTest::testParseVMS2()
|
||||
catch (PathSyntaxException&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
p.parse("[-]", Path::PATH_VMS);
|
||||
assertTrue (p.isRelative());
|
||||
assertTrue (!p.isAbsolute());
|
||||
@ -1192,7 +1192,7 @@ void PathTest::testParseVMS4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "node::device:[foo.bar]");
|
||||
|
||||
|
||||
p.parse("node::device:[foo.bar.][goo]", Path::PATH_VMS);
|
||||
assertTrue (!p.isRelative());
|
||||
assertTrue (p.isAbsolute());
|
||||
@ -1205,7 +1205,7 @@ void PathTest::testParseVMS4()
|
||||
assertTrue (p.isDirectory());
|
||||
assertTrue (!p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_VMS) == "node::device:[foo.bar.goo]");
|
||||
|
||||
|
||||
p.parse("[]foo.txt", Path::PATH_VMS);
|
||||
assertTrue (p.isRelative());
|
||||
assertTrue (!p.isAbsolute());
|
||||
@ -1333,7 +1333,7 @@ void PathTest::testParseGuess()
|
||||
assertTrue (p.getDevice() == "c");
|
||||
assertTrue (!p.isDirectory());
|
||||
assertTrue (p.isFile());
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\WinNT");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\WinNT");
|
||||
|
||||
p.parse("foo:bar.txt;5", Path::PATH_GUESS);
|
||||
assertTrue (!p.isRelative());
|
||||
@ -1382,12 +1382,12 @@ void PathTest::testStatics()
|
||||
assertTrue (!s.empty());
|
||||
Path p(s);
|
||||
assertTrue (p.isDirectory() && p.isAbsolute());
|
||||
|
||||
|
||||
s = Path::home();
|
||||
assertTrue (!s.empty());
|
||||
p = s;
|
||||
assertTrue (p.isDirectory() && p.isAbsolute());
|
||||
|
||||
|
||||
s = Path::temp();
|
||||
assertTrue (!s.empty());
|
||||
p = s;
|
||||
@ -1405,17 +1405,17 @@ void PathTest::testBaseNameExt()
|
||||
assertTrue (p.getFileName() == "foo.bar");
|
||||
assertTrue (p.getBaseName() == "foo");
|
||||
assertTrue (p.getExtension() == "bar");
|
||||
|
||||
|
||||
p.setBaseName("readme");
|
||||
assertTrue (p.getFileName() == "readme.bar");
|
||||
assertTrue (p.getBaseName() == "readme");
|
||||
assertTrue (p.getExtension() == "bar");
|
||||
|
||||
|
||||
p.setExtension("txt");
|
||||
assertTrue (p.getFileName() == "readme.txt");
|
||||
assertTrue (p.getBaseName() == "readme");
|
||||
assertTrue (p.getExtension() == "txt");
|
||||
|
||||
|
||||
p.setExtension("html");
|
||||
assertTrue (p.getFileName() == "readme.html");
|
||||
assertTrue (p.getBaseName() == "readme");
|
||||
@ -1434,7 +1434,7 @@ void PathTest::testAbsolute()
|
||||
Path rel("Poco");
|
||||
Path abs = rel.absolute(base);
|
||||
assertTrue (abs.toString(Path::PATH_WINDOWS) == "C:\\Program Files\\Poco");
|
||||
|
||||
|
||||
base.parse("/usr/local", Path::PATH_UNIX);
|
||||
rel.parse("Poco/include", Path::PATH_UNIX);
|
||||
abs = rel.absolute(base);
|
||||
@ -1516,7 +1516,7 @@ void PathTest::testExpand()
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
std::string s = Path::expand("~/.bashrc");
|
||||
assertTrue (s == Path::expand("$HOME/.bashrc"));
|
||||
assertTrue (s == Environment::get("HOME") + "/.bashrc" ||
|
||||
assertTrue (s == Environment::get("HOME") + "/.bashrc" ||
|
||||
s == Environment::get("HOME") + "//.bashrc");
|
||||
Path p(s);
|
||||
s = Path::expand("$HOME/.bashrc");
|
||||
@ -1565,7 +1565,7 @@ void PathTest::testFind()
|
||||
#endif
|
||||
assertTrue (found);
|
||||
assertTrue (!notfound);
|
||||
|
||||
|
||||
std::string fn = p.toString();
|
||||
assertTrue (fn.size() > 0);
|
||||
}
|
||||
@ -1586,15 +1586,15 @@ void PathTest::testResolve()
|
||||
Path p("c:\\foo\\", Path::PATH_WINDOWS);
|
||||
p.resolve("test.dat");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\foo\\test.dat");
|
||||
|
||||
|
||||
p.assign("c:\\foo\\", Path::PATH_WINDOWS);
|
||||
p.resolve(Path("d:\\bar.txt", Path::PATH_WINDOWS));
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "d:\\bar.txt");
|
||||
|
||||
|
||||
p.assign("c:\\foo\\bar.txt", Path::PATH_WINDOWS);
|
||||
p.resolve("foo.txt");
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\foo\\foo.txt");
|
||||
|
||||
|
||||
p.assign("c:\\foo\\bar\\", Path::PATH_WINDOWS);
|
||||
p.resolve(Path("..\\baz\\test.dat", Path::PATH_WINDOWS));
|
||||
assertTrue (p.toString(Path::PATH_WINDOWS) == "c:\\foo\\baz\\test.dat");
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
initialize();
|
||||
open();
|
||||
}
|
||||
|
||||
|
||||
~ArchiveImpl()
|
||||
{
|
||||
try
|
||||
@ -54,27 +54,27 @@ public:
|
||||
poco_unexpected();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const std::string& path() const
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
|
||||
std::size_t size() const
|
||||
{
|
||||
return _entries.size();
|
||||
}
|
||||
|
||||
|
||||
Archive::ConstIterator begin() const
|
||||
{
|
||||
return _entries.begin();
|
||||
}
|
||||
|
||||
|
||||
Archive::ConstIterator end() const
|
||||
{
|
||||
return _entries.end();
|
||||
}
|
||||
|
||||
|
||||
std::string extract(const ArchiveEntry& entry, const std::string& destPath)
|
||||
{
|
||||
Poco::Path basePath;
|
||||
@ -91,19 +91,19 @@ public:
|
||||
Poco::Path extractedPath(basePath);
|
||||
extractedPath.append(entryPath);
|
||||
extractedPath.makeAbsolute();
|
||||
|
||||
|
||||
if (entry.isFile())
|
||||
{
|
||||
{
|
||||
Poco::UInt32 blockIndex = 0;
|
||||
Byte* pOutBuffer = 0;
|
||||
std::size_t outBufferSize = 0;
|
||||
std::size_t offset = 0;
|
||||
std::size_t extractedSize = 0;
|
||||
int err = SzArEx_Extract(
|
||||
&_db,
|
||||
&_lookStream.s,
|
||||
entry.index(),
|
||||
&blockIndex,
|
||||
&_db,
|
||||
&_lookStream.s,
|
||||
entry.index(),
|
||||
&blockIndex,
|
||||
&pOutBuffer,
|
||||
&outBufferSize,
|
||||
&offset,
|
||||
@ -115,7 +115,7 @@ public:
|
||||
try
|
||||
{
|
||||
poco_assert (extractedSize == entry.size());
|
||||
|
||||
|
||||
Poco::Path parent = extractedPath.parent();
|
||||
Poco::File dir(parent.toString());
|
||||
dir.createDirectories();
|
||||
@ -140,10 +140,10 @@ public:
|
||||
Poco::File dir(extractedPath.toString());
|
||||
dir.createDirectories();
|
||||
}
|
||||
|
||||
|
||||
return extractedPath.toString();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
void initialize()
|
||||
{
|
||||
@ -162,20 +162,15 @@ protected:
|
||||
{
|
||||
checkFile();
|
||||
|
||||
#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
|
||||
#if defined(_WIN32)
|
||||
std::wstring wpath;
|
||||
Poco::UnicodeConverter::toUTF16(_path, wpath);
|
||||
if (InFile_OpenW(&_archiveStream.file, wpath.c_str()) != SZ_OK)
|
||||
{
|
||||
throw Poco::OpenFileException(_path);
|
||||
}
|
||||
#else
|
||||
if (InFile_Open(&_archiveStream.file, _path.c_str()) != SZ_OK)
|
||||
{
|
||||
throw Poco::OpenFileException(_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
_lookStream.realStream = &_archiveStream.s;
|
||||
LookToRead_Init(&_lookStream);
|
||||
|
||||
@ -185,29 +180,29 @@ protected:
|
||||
{
|
||||
loadEntries();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
handleError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void close()
|
||||
{
|
||||
SzArEx_Free(&_db, &_szAlloc);
|
||||
File_Close(&_archiveStream.file);
|
||||
}
|
||||
|
||||
|
||||
void loadEntries()
|
||||
{
|
||||
_entries.reserve(_db.db.NumFiles);
|
||||
for (Poco::UInt32 i = 0; i < _db.db.NumFiles; i++)
|
||||
{
|
||||
const CSzFileItem *f = _db.db.Files + i;
|
||||
|
||||
|
||||
ArchiveEntry::EntryType type = f->IsDir ? ArchiveEntry::ENTRY_DIRECTORY : ArchiveEntry::ENTRY_FILE;
|
||||
Poco::UInt32 attributes = f->AttribDefined ? f->Attrib : 0;
|
||||
Poco::UInt64 size = f->Size;
|
||||
|
||||
|
||||
std::vector<Poco::UInt16> utf16Path;
|
||||
std::size_t utf16PathLen = SzArEx_GetFileNameUtf16(&_db, i, 0);
|
||||
utf16Path.resize(utf16PathLen, 0);
|
||||
@ -218,7 +213,7 @@ protected:
|
||||
Poco::TextConverter converter(utf16Encoding, utf8Encoding);
|
||||
std::string utf8Path;
|
||||
converter.convert(&utf16Path[0], (int) utf16PathLen*sizeof(Poco::UInt16), utf8Path);
|
||||
|
||||
|
||||
Poco::Timestamp lastModified(0);
|
||||
if (f->MTimeDefined)
|
||||
{
|
||||
@ -228,12 +223,12 @@ protected:
|
||||
tv /= 10;
|
||||
lastModified = tv;
|
||||
}
|
||||
|
||||
|
||||
ArchiveEntry entry(type, utf8Path, size, lastModified, attributes, i);
|
||||
_entries.push_back(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkFile()
|
||||
{
|
||||
Poco::File f(_path);
|
||||
@ -250,13 +245,13 @@ protected:
|
||||
throw Poco::FileAccessDeniedException(_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void handleError(int err)
|
||||
{
|
||||
std::string arg;
|
||||
handleError(err, arg);
|
||||
}
|
||||
|
||||
|
||||
void handleError(int err, const std::string& arg)
|
||||
{
|
||||
switch (err)
|
||||
@ -308,7 +303,7 @@ Archive::Archive(const std::string& path):
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
Archive::~Archive()
|
||||
{
|
||||
delete _pImpl;
|
||||
@ -320,7 +315,7 @@ const std::string& Archive::path() const
|
||||
return _pImpl->path();
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::size_t Archive::size() const
|
||||
{
|
||||
return _pImpl->size();
|
||||
@ -332,7 +327,7 @@ Archive::ConstIterator Archive::begin() const
|
||||
return _pImpl->begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Archive::ConstIterator Archive::end() const
|
||||
{
|
||||
return _pImpl->end();
|
||||
@ -365,7 +360,7 @@ void Archive::extract(const std::string& destPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string Archive::extract(const ArchiveEntry& entry, const std::string& destPath)
|
||||
{
|
||||
return _pImpl->extract(entry, destPath);
|
||||
|
Loading…
Reference in New Issue
Block a user