Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
Copy.cpp File Reference
#include "Copy.h"
#include "nsIComponentManager.h"
#include "nsILocalFile.h"
#include "nsXPIDLString.h"

Go to the source code of this file.

Defines

#define kRegTreeCopy   (NS_LITERAL_STRING("Copy"))
#define kRegKeyRemote   (NS_LITERAL_STRING("RemoteDir"))

Functions

static nsresult CopyFile (nsCOMPtr< nsIFile > fromDir, nsCOMPtr< nsIFile > toDir, nsAString &fileSubPath)
static void AppendElementsToStrArray (nsCStringArray &target, nsCStringArray &source)

Define Documentation

#define kRegKeyRemote   (NS_LITERAL_STRING("RemoteDir"))

Definition at line 45 of file Copy.cpp.

Definition at line 44 of file Copy.cpp.


Function Documentation

static void AppendElementsToStrArray ( nsCStringArray &  target,
nsCStringArray &  source 
) [static]

Definition at line 87 of file Copy.cpp.

{
  for (PRInt32 i = source.Count() - 1; i >= 0; i--)
    target.AppendCString(*source.CStringAt(i));
}

Here is the caller graph for this function:

static nsresult CopyFile ( nsCOMPtr< nsIFile fromDir,
nsCOMPtr< nsIFile toDir,
nsAString &  fileSubPath 
) [static]

Definition at line 51 of file Copy.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIFile> fromFile;
  rv = fromDir->Clone(getter_AddRefs(fromFile));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = fromFile->Append(fileSubPath);
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIFile> toFileOld;
  rv = toDir->Clone(getter_AddRefs(toFileOld));
  NS_ENSURE_SUCCESS(rv, rv);

  rv = toFileOld->Append(fileSubPath);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool exists;
  rv = fromFile->Exists(&exists);
  NS_ENSURE_SUCCESS(rv, rv);

  if (exists)
  {
    rv = toFileOld->Remove(PR_FALSE);
    rv = fromFile->CopyTo(toDir, fileSubPath);
  }
  else
  {
    rv = NS_ERROR_FILE_NOT_FOUND;
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function: