summaryrefslogtreecommitdiffstats
path: root/libhb/ports.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-03-19 18:54:37 +0000
committerjstebbins <[email protected]>2011-03-19 18:54:37 +0000
commitde22836e9e399616ea04051eabd8b8cbedb4e8cb (patch)
treea2bbbfcf9a86bc0de764ef1973d2abb507e2c8d4 /libhb/ports.c
parent6fd4cbe2420946f08602f61c84730c1fa927554a (diff)
Use TEMP or TEMPDIR environment variables for location of tmp directory
Falls back to /tmp if neither are set. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3852 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/ports.c')
-rw-r--r--libhb/ports.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libhb/ports.c b/libhb/ports.c
index 64aad0e77..722134780 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -230,10 +230,10 @@ int hb_get_cpu_count()
void hb_get_temporary_directory( char path[512] )
{
char base[512];
+ char *p;
/* Create the base */
#if defined( SYS_CYGWIN ) || defined( SYS_MINGW )
- char *p;
int i_size = GetTempPath( 512, base );
if( i_size <= 0 || i_size >= 512 )
{
@@ -245,7 +245,11 @@ void hb_get_temporary_directory( char path[512] )
while( ( p = strchr( base, '\\' ) ) )
*p = '/';
#else
- strcpy( base, "/tmp" );
+ if( (p = getenv( "TMPDIR" ) ) != NULL ||
+ (p = getenv( "TEMP" ) ) != NULL )
+ strcpy( base, p );
+ else
+ strcpy( base, "/tmp" );
#endif
/* I prefer to remove evntual last '/' (for cygwin) */
if( base[strlen(base)-1] == '/' )