Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsCommandLineService.cpp File Reference
#include "nsICmdLineService.h"
#include "nsCommandLineService.h"
#include "nsIComponentManager.h"
#include "nsILocalFile.h"
#include "nsString.h"
#include "plstr.h"
#include "nsCRT.h"
#include "nsNetUtil.h"

Go to the source code of this file.

Functions

static voidProcessURLArg (char *str)

Function Documentation

static void* ProcessURLArg ( char *  str) [static]

Definition at line 61 of file nsCommandLineService.cpp.

{
  // Problem: since the arg parsing code doesn't know which flags
  // take arguments, it always calls this method for the last
  // non-flag argument. But sometimes that argument is actually
  // the arg for the last switch, e.g. -width 500 or -Profile default.
  // nsLocalFile will only work on absolute pathnames, so return
  // if str doesn't start with '/' or '\'.
  if (str && (*str == '\\' || *str == '/'))
  {
    nsCOMPtr<nsIURI> uri;
    nsresult rv = NS_NewURI(getter_AddRefs(uri), str);
    if (NS_FAILED(rv))
    {
      nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
      if (file)
      {
        rv = file->InitWithNativePath(nsDependentCString(str));
        if (NS_SUCCEEDED(rv))
        {
          nsCAutoString fileurl;
          rv = NS_GetURLSpecFromFile(file, fileurl);
          if (NS_SUCCEEDED(rv))
            return NS_REINTERPRET_CAST(void*, ToNewCString(fileurl));
        }
      }
    }
  }

  return NS_REINTERPRET_CAST(void*, nsCRT::strdup(str));
}

Here is the call graph for this function: