1. added wxFileName::CreateTempFileName() and implemented it properly (using

mkstemp() when available)
2. wxTempFile::Open() and wxGetTempFileName() now use CreateTempFileName()
   avoiding code duplication
3. updated the docs


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-12-01 17:18:11 +00:00
parent 1d21855083
commit ade35f11fe
11 changed files with 543 additions and 352 deletions

View File

@@ -844,6 +844,35 @@ static void TestFileNameSplit()
}
}
static void TestFileNameTemp()
{
puts("*** testing wxFileName temp file creation ***");
static const char *tmpprefixes[] =
{
"foo",
"/tmp/foo",
"..",
"../bar",
"/tmp/foo/bar", // this one must be an error
};
for ( size_t n = 0; n < WXSIZEOF(tmpprefixes); n++ )
{
wxString path = wxFileName::CreateTempFileName(tmpprefixes[n]);
if ( !path.empty() )
{
printf("Prefix '%s'\t-> temp file '%s'\n",
tmpprefixes[n], path.c_str());
if ( !wxRemoveFile(path) )
{
wxLogWarning("Failed to remove temp file '%s'", path.c_str());
}
}
}
}
static void TestFileNameComparison()
{
// TODO!
@@ -5187,10 +5216,11 @@ int main(int argc, char **argv)
#endif // TEST_FILE
#ifdef TEST_FILENAME
TestFileNameConstruction();
TestFileNameSplit();
TestFileNameTemp();
if ( 0 )
{
TestFileNameConstruction();
TestFileNameSplit();
TestFileNameCwd();
TestFileNameComparison();
TestFileNameOperations();