function advagg_file_save_data in Advanced CSS/JS Aggregation 6
Same name and namespace in other branches
- 7 advagg.module \advagg_file_save_data()
Save a string to the specified destination.
Parameters
$data A string containing the contents of the file.:
$dest A string containing the destination location.:
$replace Replace behavior when the destination file already exists.:
- FILE_EXISTS_REPLACE - Replace the existing file
- FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique
- FILE_EXISTS_ERROR - Do nothing and return FALSE.
Return value
A string containing the resulting filename or 0 on error
See also
1 call to advagg_file_save_data()
- advagg_htaccess_check_generate in ./
advagg.module - Generate .htaccess rules and place them in advagg dir
2 string references to 'advagg_file_save_data'
- advagg_file_saver in ./
advagg.module - Save a string to the specified destination. Verify that file size is not zero.
- advagg_js_compress_file_saver in advagg_js_compress/
advagg_js_compress.module - Save a string to the specified destination. Verify that file size is not zero.
File
- ./
advagg.module, line 1306 - Advanced CSS/JS aggregation module
Code
function advagg_file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
$temp = file_directory_temp();
// On Windows, tempnam() requires an absolute path, so we use realpath().
$file = tempnam(realpath($temp), 'file');
if (!($fp = fopen($file, 'wb'))) {
drupal_set_message(t('The file could not be created.'), 'error');
return 0;
}
fwrite($fp, $data);
fclose($fp);
if (!advagg_file_move($file, $dest, $replace)) {
return 0;
}
return $file;
}