tmpdir.c File Reference

#include <stdio.h>
#include "machine.h"
#include "../../../io/includes/createdir.h"
#include "MALLOC.h"
#include "prompt.h"
#include "tmpdir.h"

Include dependency graph for tmpdir.c:

Go to the source code of this file.

Functions

char * getenv ()
void C2F() settmpdir (void)
char * get_sci_tmp_dir (void)
void C2F() tmpdirc (void)

Variables

static char tmp_dir [256]
static char buf [256]


Function Documentation

char* get_sci_tmp_dir ( void   ) 

get a reference to tmp_dir

Definition at line 93 of file tmpdir.c.

References C2F, settmpdir(), and tmp_dir.

Referenced by CreateCppShared(), CreateShared(), and tmpdirc().

00094 {
00095   /* just in case */
00096   C2F(settmpdir)();
00097   return tmp_dir;
00098 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* getenv (  ) 

void C2F() settmpdir ( void   ) 

creates a tmp dir for a scilab session and fixes the TMPDIR env variable

Definition at line 38 of file tmpdir.c.

References buf, CreateDir(), FALSE, first, getpid(), NULL, PATH_MAX, putenv, and tmp_dir.

00039 {
00040 #ifdef _MSC_VER
00041         #define PATH_MAX 1024
00042         char TmpDirDefault[PATH_MAX];
00043 #endif
00044   static int first =0;
00045   if ( first == 0 ) 
00046     {
00047       first++;
00048 #ifdef _MSC_VER 
00049           if (!GetTempPath(PATH_MAX,TmpDirDefault))
00050           {
00051                   MessageBox(NULL,"Don''t find Windows temporary directory","Error",MB_ICONERROR);
00052                   exit(1);
00053           }
00054           else
00055           {
00056                   sprintf(tmp_dir,"%sSCI_TMP_%d_",TmpDirDefault,(int) _getpid());
00057           }
00058 
00059           if ( CreateDirectory(tmp_dir,NULL)==FALSE)
00060       {
00061                 DWORD attribs=GetFileAttributes (tmp_dir); 
00062 
00063                 if (attribs & FILE_ATTRIBUTE_DIRECTORY)
00064                 {
00065                   // Repertoire existant
00066                 }
00067                 else
00068                 {
00069                   #ifdef _DEBUG
00070                   char MsgErr[1024];
00071                   wsprintf(MsgErr,"Impossible to create : %s",tmp_dir);
00072                   MessageBox(NULL,MsgErr,"Error",MB_ICONERROR);
00073                   exit(1);
00074                   #else
00075                   GetTempPath(PATH_MAX,TmpDirDefault);
00076                   sprintf(tmp_dir,"%s",TmpDirDefault);
00077                   tmp_dir[strlen(tmp_dir)-1]='\0'; /* Remove last \ */
00078                   #endif
00079                 }
00080   }
00081 #else 
00082   sprintf(tmp_dir,"/tmp/SD_%d_",(int) getpid());
00083   CreateDir(tmp_dir) ;
00084 #endif 
00085   sprintf(buf,"TMPDIR=%s",tmp_dir);
00086   putenv(buf);
00087     }
00088 }

Here is the call graph for this function:

void C2F() tmpdirc ( void   ) 

remove TMPDIR directory

Definition at line 103 of file tmpdir.c.

References get_sci_tmp_dir(), and RemoveDir().

00104 {
00105   char *tmp_dir2 = get_sci_tmp_dir(); 
00106   RemoveDir(tmp_dir2);
00107 }

Here is the call graph for this function:


Variable Documentation

char buf[256] [static]

Definition at line 32 of file tmpdir.c.

char tmp_dir[256] [static]

Definition at line 32 of file tmpdir.c.

Referenced by get_sci_tmp_dir(), and settmpdir().


Generated on Sun Mar 4 15:17:29 2007 for Scilab [trunk] by  doxygen 1.5.1