public static function ProcessFile($p_tmpFile, $p_newFile, $p_charset = null)
{
// remove existing file if one exists
if (file_exists($p_newFile) && !is_dir($p_newFile)) {
if (!unlink($p_newFile)) {
return new PEAR_Error(camp_get_error_message(CAMP_ERROR_DELETE_FILE, $p_newFile), CAMP_ERROR_DELETE_FILE);
}
}
$fileName = basename($p_newFile);
$fileType = @mime_content_type($p_tmpFile);
if (!empty($p_charset)) {
if (strncmp($fileType, 'text', 4) == 0) {
$success = self::ChangeCharset($p_tmpFile, $p_newFile, $fileType, $p_charset);
} else {
$success = rename($p_tmpFile, $p_newFile);
}
if (PEAR::isError($success) || !$success) {
return $success;
}
} else {
$success = rename($p_tmpFile, $p_newFile);
if (!$success) {
return new PEAR_Error(camp_get_error_message(CAMP_ERROR_CREATE_FILE, $fileName), CAMP_ERROR_CREATE_FILE);
}
}
self::UpdateStatus();
return true;
}