Gin
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ElevatedFileCopy Class Reference

Copies files, creating folders where required requesting admin access only if required. More...

Public Types

enum  Result { success , failed , cancelled , nopermissions }
 

Public Member Functions

void createDir (const juce::File &dir)
 Add a directory to create. More...
 
void copyFile (const juce::File &src, const juce::File &dst)
 Add a file to copy. More...
 
void moveFile (const juce::File &src, const juce::File &dst)
 Add a file to move. More...
 
void deleteFile (const juce::File &f)
 Delete a file or directory. More...
 
Result execute (bool launchSelf=false)
 Perform the copy. More...
 
void clear ()
 Clear all files to be copied. More...
 

Static Public Member Functions

static bool processCommandLine (juce::String commandLine)
 Call from JUCEApplication::initialise() and abort the initialise process if returns true. More...
 
static Result runScriptWithAdminAccess (juce::File script, bool launchSelf)
 Run a script as root. More...
 

Detailed Description

Copies files, creating folders where required requesting admin access only if required.

Member Enumeration Documentation

◆ Result

Enumerator
success 
failed 
cancelled 
nopermissions 

Member Function Documentation

◆ createDir()

void ElevatedFileCopy::createDir ( const juce::File &  dir)

Add a directory to create.

◆ copyFile()

void ElevatedFileCopy::copyFile ( const juce::File &  src,
const juce::File &  dst 
)

Add a file to copy.

src and dst must be complete file names, neither can be a directory

◆ moveFile()

void ElevatedFileCopy::moveFile ( const juce::File &  src,
const juce::File &  dst 
)

Add a file to move.

src and dst must be complete file names, neither can be a directory

◆ deleteFile()

void ElevatedFileCopy::deleteFile ( const juce::File &  f)

Delete a file or directory.

◆ execute()

Result ElevatedFileCopy::execute ( bool  launchSelf = false)

Perform the copy.

If launchSelf is false, then on Windows cmd.exe will be executed with admin permissions to copy the files. This looks odd to the user since Windows Command Processor will ask for permissions to make changes rather than your app. Pass true to make your app get launched with admin permissions instead. In this case, you must call processCommandLine from yours apps initialise instead, and if it returns true, return from initialise asap and your app will quit as it's just a temporary process.

◆ clear()

void ElevatedFileCopy::clear ( )

Clear all files to be copied.

◆ processCommandLine()

static bool ElevatedFileCopy::processCommandLine ( juce::String  commandLine)
static

Call from JUCEApplication::initialise() and abort the initialise process if returns true.

◆ runScriptWithAdminAccess()

static Result ElevatedFileCopy::runScriptWithAdminAccess ( juce::File  script,
bool  launchSelf 
)
static

Run a script as root.

See execute for the meaning of launch self


The documentation for this class was generated from the following file: