Beispiel #1
0
static void osd_setWorkingDirectory (void)
{
# if defined (UNIX)
  char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN);
  char *cwd = getcwd (buf, MAXPATHLEN);
#elif defined (OS2)
  char *buf = dmalloc (sizeof (*buf) * MAXPATHLEN);
  char *cwd = _getcwd2 (buf, MAXPATHLEN);
  char *slash;
  while ((slash = strchr (cwd, '/')) != NULL)
    {
      *slash = '\\';
    }
#endif
# if defined (UNIX) || defined (OS2)
  llassert (cstring_isUndefined (osd_cwd));

  if (cwd == NULL)
    {
      lldiagmsg (message ("Cannot get working directory: %s\n",
			  lldecodeerror (errno)));
      osd_cwd = cstring_makeLiteral ("<missing directory>");
    }
  else
    {
      osd_cwd = cstring_fromCharsNew (cwd);
    }

  sfree (buf);
# else
  ; /* Don't know how to do this for non-POSIX platforms */
# endif
}
Beispiel #2
0
char * 
gs_getcwd(char *dirname, int size)
{
#ifdef __BORLANDC__
	return getcwd(dirname, size);
#else
	return _getcwd2(dirname, size);
#endif
}
Beispiel #3
0
char *SLpath_getcwd (void)
{
   char cwd[4096];
   char *p;
   size_t len;

#ifndef HAVE_GETCWD
   p = getwd (cwd);
#else
# if defined (__EMX__)
   p = _getcwd2(cwd, sizeof(cwd));	       /* includes drive specifier */
# else
   p = getcwd(cwd, sizeof(cwd));	       /* djggp includes drive specifier */
# endif
#endif

   if (p == NULL)
     return NULL;

#ifdef IBMPC_SYSTEM
   convert_slashes (cwd);
#endif

   len = strlen (cwd);

   p = (char *) SLmalloc (len+2);      /* \0 + trailing / */
   if (p == NULL)
     {
#ifdef ENOMEM
	errno = ENOMEM;
#endif
	return NULL;
     }

   strcpy (p, cwd);

#ifndef VMS
   if (len && (p[len-1] != PATH_SEP))
     {
	p[len++] = PATH_SEP;
	p[len] = 0;
     }
#endif

   return p;
}
Beispiel #4
0
GooString *getCurrentDir() {
    char buf[PATH_MAX+1];

#if defined(__EMX__)
    if (_getcwd2(buf, sizeof(buf)))
#elif defined(WIN32)
    if (GetCurrentDirectory(sizeof(buf), buf))
#elif defined(ACORN)
    if (strcpy(buf, "@"))
#elif defined(MACOS)
    if (strcpy(buf, ":"))
#else
    if (getcwd(buf, sizeof(buf)))
#endif
        return new GooString(buf);
    return new GooString();
}
Beispiel #5
0
/* to handle the drive letter and DBCS characters within a given path */
char *
getcwd(char *path, size_t len)
{
    return _getcwd2(path, (int)len);
}
Beispiel #6
0
//------------------------------------------------------------------------
//          XPI_Init()
//------------------------------------------------------------------------
PR_PUBLIC_API(nsresult) XPI_Init( const char*         aProgramDir,
                                  const char*         aLogName,
                                  pfnXPIProgress      progressCB )
{
    nsresult              rv;

    //--------------------------------------------------------------------
    // Initialize XPCOM and AutoRegister() its components
    //--------------------------------------------------------------------
#if defined(XP_WIN) || defined(XP_OS2)

 #ifdef XP_OS2_EMX
    char componentPath[MAX_PATH];
    _getcwd2(componentPath, MAX_PATH);
    int len = strlen(componentPath);
    for (int i = 0; i < len; i++) {
      if (componentPath[i] == '/') {
        componentPath[i] = '\\';
      }
    }
 #else
    char componentPath[MAX_PATH];
    getcwd(componentPath, MAX_PATH);
 #endif

    nsCOMPtr<nsILocalFile> file;
    rv = NS_NewNativeLocalFile(nsDependentCString(componentPath), PR_TRUE, getter_AddRefs(file));
    if (NS_FAILED(rv)) return rv;
    
    rv = NS_InitXPCOM2(&gServiceMgr, file, nsnull); 

#elif defined(XP_UNIX)

    rv = NS_InitXPCOM2(&gServiceMgr, nsnull, nsnull); 

    char cwd[1024];
    char compDirPath[1024];

    memset(cwd, 0, 1024);
    memset(compDirPath, 0, 1024);
    getcwd(cwd, 1024);
    sprintf(compDirPath, "%s/components", cwd);

    nsCOMPtr<nsILocalFile> compDir;
    NS_NewNativeLocalFile(nsDependentCString(compDirPath), PR_TRUE, getter_AddRefs(compDir));

#else

    rv = NS_InitXPCOM2(&gServiceMgr, NULL, NULL);

#endif

    if (NS_FAILED(rv))
        return rv;

    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(gServiceMgr);
    NS_ASSERTION(registrar, "Null nsIComponentRegistrar");

#if defined(XP_UNIX)
    rv = registrar->AutoRegister(compDir);
#else
    rv = registrar->AutoRegister(nsnull);
#endif
    if (NS_FAILED(rv))
        return rv;


    //--------------------------------------------------------------------
    // Get the SoftwareUpdate (XPInstall) service.
    //
    // Since AppShell is not started by XPIStub the XPI service is never 
    // registered with the service manager. We keep a local pointer to it 
    // so it stays alive througout.
    //--------------------------------------------------------------------
    rv = CallCreateInstance(kSoftwareUpdateCID, &gXPI);
    if (NS_FAILED(rv))
        return rv;


    //--------------------------------------------------------------------
    // Override XPInstall's natural assumption that the current executable
    // is Mozilla. Use the given directory as the "Program" folder.
    //--------------------------------------------------------------------
    nsCOMPtr<nsPIXPIStubHook>   hook = do_QueryInterface(gXPI);
    nsCOMPtr<nsILocalFile>      iDirSpec;
  
    if (aProgramDir)
    {
	NS_NewNativeLocalFile(nsDependentCString(aProgramDir), PR_TRUE, getter_AddRefs(iDirSpec));
    }
    else
    {
       nsCOMPtr<nsIProperties> directoryService = 
          do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);

       directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile), 
                             getter_AddRefs(iDirSpec));
    }

    if (hook && iDirSpec)
    {
        rv = hook->StubInitialize( iDirSpec, aLogName );
        if (NS_FAILED(rv)) return rv;
    }
    else
        return NS_ERROR_NULL_POINTER;


    //--------------------------------------------------------------------
    // Save the install wizard's callbacks as a nsIXPINotifer for later
    //--------------------------------------------------------------------
    nsStubListener* stub = new nsStubListener( progressCB );
    if (!stub)
    {
        gXPI->Release();
        rv = NS_ERROR_OUT_OF_MEMORY;
    }
    else
    {
        rv = stub->QueryInterface(NS_GET_IID(nsIXPIListener), (void**)&gListener);
    }
    return rv;
}