-- | Delete file (which can be a file or wildcard, but should be specified with a full path) from the target system.
--   If 'RebootOK' is specified and the file cannot be deleted then the file is deleted when the system reboots --
--   if the file will be deleted on a reboot, the reboot flag will be set. The error flag is set if files are found
--   and cannot be deleted. The error flag is not set from trying to delete a file that does not exist.
--
-- > delete [] "$INSTDIR/somefile.dat"
delete :: [Attrib] -> Exp FilePath -> Action ()
delete as x = do
    Value x <- x
    emit $ Delete $ foldl f def{delFile=x} as
    where
        f c RebootOK = c{delRebootOK=True}
        f c x = error $ "Invalid attribute to delete: " ++ show x

-- | Remove the specified directory (fully qualified path with no wildcards). Without 'Recursive',
--   the directory will only be removed if it is completely empty. If 'Recursive' is specified, the
--   directory will be removed recursively, so all directories and files in the specified directory
--   will be removed. If 'RebootOK' is specified, any file or directory which could not have been
--   removed during the process will be removed on reboot -- if any file or directory will be
--   removed on a reboot, the reboot flag will be set.
--   The error flag is set if any file or directory cannot be removed.
--
-- > rmdir [] "$INSTDIR"
-- > rmdir [] "$INSTDIR/data"
-- > rmdir [Recursive, RebootOK] "$INSTDIR"
-- > rmdir [RebootOK] "$INSTDIR/DLLs"
--
--   Note that the current working directory can not be deleted. The current working directory is
--   set by 'setOutPath'. For example, the following example will not delete the directory.
--
-- > setOutPath "$TEMP/dir"
-- > rmdir [] "$TEMP/dir"
--
--   The next example will succeed in deleting the directory.
--
-- > setOutPath "$TEMP/dir"
-- > setOutPath "$TEMP"
-- > rmdir [] "$TEMP/dir"
--
--   Warning: using @rmdir [Recursive] "$INSTDIR"@ in 'uninstall' is not safe. Though it is unlikely,
--   the user might select to install to the Program Files folder and so this command will wipe out
--   the entire Program Files folder, including other programs that has nothing to do with the uninstaller.
--   The user can also put other files but the program's files and would expect them to get deleted with
--   the program. Solutions are available for easily uninstalling only files which were installed by the installer.
delete :: [Attrib] -> Exp FilePath -> Action ()
delete as x = do
    Value x <- x
    emit $ Delete $ foldl f def{delFile=x} as
    where
        f c RebootOK = c{delRebootOK=True}
        f c x = error $ "Invalid attribute to delete: " ++ show x

-- | Remove the specified directory (fully qualified path with no wildcards). Without 'Recursive',
--   the directory will only be removed if it is completely empty. If 'Recursive' is specified, the
--   directory will be removed recursively, so all directories and files in the specified directory
--   will be removed. If 'RebootOK' is specified, any file or directory which could not have been
--   removed during the process will be removed on reboot -- if any file or directory will be
--   removed on a reboot, the reboot flag will be set.
--   The error flag is set if any file or directory cannot be removed.
--
-- > rmdir [] "$INSTDIR"
-- > rmdir [] "$INSTDIR/data"
-- > rmdir [Recursive, RebootOK] "$INSTDIR"
-- > rmdir [RebootOK] "$INSTDIR/DLLs"
--
--   Note that the current working directory can not be deleted. The current working directory is
--   set by 'setOutPath'. For example, the following example will not delete the directory.
--
-- > setOutPath "$TEMP/dir"
-- > rmdir [] "$TEMP/dir"
--
--   The next example will succeed in deleting the directory.
--
-- > setOutPath "$TEMP/dir"
-- > setOutPath "$TEMP"
-- > rmdir [] "$TEMP/dir"
--
--   Warning: using @rmdir [Recursive] "$INSTDIR"@ in 'uninstall' is not safe. Though it is unlikely,
--   the user might select to install to the Program Files folder and so this command will wipe out
--   the entire Program Files folder, including other programs that has nothing to do with the uninstaller.
--   The user can also put other files but the program's files and would expect them to get deleted with
--   the program. Solutions are available for easily uninstalling only files which were installed by the installer.
delete as x = do
    Value x <- x
    emit $ Delete $ foldl f def{delFile=x} as
    where
        f c RebootOK = c{delRebootOK=True}
        f c x = error $ "Invalid attribute to delete: " ++ show x

-- | Remove the specified directory (fully qualified path with no wildcards). Without 'Recursive',
--   the directory will only be removed if it is completely empty. If 'Recursive' is specified, the
--   directory will be removed recursively, so all directories and files in the specified directory
--   will be removed. If 'RebootOK' is specified, any file or directory which could not have been
--   removed during the process will be removed on reboot -- if any file or directory will be
--   removed on a reboot, the reboot flag will be set.
--   The error flag is set if any file or directory cannot be removed.
--
-- > rmdir [] "$INSTDIR"
-- > rmdir [] "$INSTDIR/data"
-- > rmdir [Recursive, RebootOK] "$INSTDIR"
-- > rmdir [RebootOK] "$INSTDIR/DLLs"
--
--   Note that the current working directory can not be deleted. The current working directory is
--   set by 'setOutPath'. For example, the following example will not delete the directory.
--
-- > setOutPath "$TEMP/dir"
-- > rmdir [] "$TEMP/dir"
--
--   The next example will succeed in deleting the directory.
--
-- > setOutPath "$TEMP/dir"
-- > setOutPath "$TEMP"
-- > rmdir [] "$TEMP/dir"
--
--   Warning: using @rmdir [Recursive] "$INSTDIR"@ in 'uninstall' is not safe. Though it is unlikely,
--   the user might select to install to the Program Files folder and so this command will wipe out
--   the entire Program Files folder, including other programs that has nothing to do with the uninstaller.
--   The user can also put other files but the program's files and would expect them to get deleted with
--   the program. Solutions are available for easily uninstalling only files which were installed by the installer.