diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-06-09 11:16:58 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-06-09 11:16:58 +0000 |
commit | 5a26b12045fb40ba47565a6ab01548db699f4098 (patch) | |
tree | ee1a7f22a4c0f8fef3f4d520e2fcdd30edb1283d /psprint | |
parent | 20af5ad605aa3c3a3d73fd076f781d7464e3180c (diff) |
INTEGRATION: CWS vcl59 (1.33.24); FILE MERGED
2006/05/30 16:49:55 pl 1.33.24.3: RESYNC: (1.34-1.35); FILE MERGED
2006/05/08 11:27:14 pl 1.33.24.2: RESYNC: (1.33-1.34); FILE MERGED
2006/05/05 14:21:27 pl 1.33.24.1: #i64420# use osl_getTempDirURL instead of tempname()
Diffstat (limited to 'psprint')
-rw-r--r-- | psprint/source/printergfx/printerjob.cxx | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/psprint/source/printergfx/printerjob.cxx b/psprint/source/printergfx/printerjob.cxx index c73d6c47d550..c14e19284f42 100644 --- a/psprint/source/printergfx/printerjob.cxx +++ b/psprint/source/printergfx/printerjob.cxx @@ -4,9 +4,9 @@ * * $RCSfile: printerjob.cxx,v $ * - * $Revision: 1.35 $ + * $Revision: 1.36 $ * - * last change: $Author: vg $ $Date: 2006-05-24 12:03:19 $ + * last change: $Author: hr $ $Date: 2006-06-09 12:16:58 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -60,6 +60,9 @@ #ifndef _RTL_STRBUF_HXX_ #include <rtl/strbuf.hxx> #endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif #ifndef _OSL_THREAD_H_ #include <osl/thread.h> #endif @@ -311,35 +314,36 @@ removeSpoolDir (const rtl::OUString& rSpoolDir) system (pSystem); } -/* creates a spool directory using the environment TMPDIR, or the - standard P_tmpdir definition (/tmp for Linux and /var/tmp for Solaris) - leads to a directory like "/tmp/pspXXXXXX" */ +/* creates a spool directory with a "pidgin random" value based on + current system time */ rtl::OUString createSpoolDir () { - /* get a tmp directory */ - static char* pTmpDir = NULL; - if (pTmpDir == NULL) - { - if (! existsTmpDir(pTmpDir = getenv("TMPDIR"))) - if (! existsTmpDir(pTmpDir = P_tmpdir)) - pTmpDir = "/tmp"; - } - - /* create a subdirectory in the tmp directory */ - char* pName = tempnam (pTmpDir, "psp"); - rtl::OUString aSubDir = rtl::OUString::createFromAscii (pName); - rtl::OUString aUNCSubDir; - osl::File::getFileURLFromSystemPath (aSubDir, aUNCSubDir); - free (pName); + TimeValue aCur; + osl_getSystemTime( &aCur ); + sal_Int32 nRand = aCur.Seconds ^ (aCur.Nanosec/1000); - /* create directory with attributes */ - osl::Directory::create (aUNCSubDir); - osl::File::setAttributes (aUNCSubDir, osl_File_Attribute_OwnWrite - | osl_File_Attribute_OwnRead - | osl_File_Attribute_OwnExe ); + rtl::OUString aTmpDir; + osl_getTempDirURL( &aTmpDir.pData ); - return aUNCSubDir; + do + { + rtl::OUStringBuffer aDir( aTmpDir.getLength() + 16 ); + aDir.append( aTmpDir ); + aDir.appendAscii( "/psp" ); + aDir.append(nRand); + rtl::OUString aResult = aDir.makeStringAndClear(); + if( osl::Directory::create( aResult ) == osl::FileBase::E_None ) + { + osl::File::setAttributes( aResult, + osl_File_Attribute_OwnWrite + | osl_File_Attribute_OwnRead + | osl_File_Attribute_OwnExe ); + return aResult; + } + nRand++; + } while( nRand ); + return rtl::OUString(); } } // namespace psp |