Commit 382b6b6f authored by Jakob Petsovits's avatar Jakob Petsovits

#269073 by Crell and jpetso: Initial Drupal 6 port of filefield.

Don't expect anything usable yet - it works, but still has a long way to go.

Thanks a lot to Crell for getting this thing rolling.
parent adb434fc
......@@ -12,6 +12,10 @@
function field_file_load($fid, $reset = NULL) {
static $files = array();
if (empty($fid)) {
return FALSE;
}
// Reset internal cache.
if ($reset) {
$files = array();
......@@ -29,6 +33,10 @@ function field_file_load($fid, $reset = NULL) {
$file = db_fetch_object(db_query("SELECT f.* FROM {files} f WHERE f.filepath = '%s'", $fid));
}
if (!$file) {
return FALSE;
}
module_invoke_all('file', 'load', $file);
// Cache the fully loaded value by both fid and filepath.
......@@ -110,7 +118,6 @@ function field_file_delete($file, $force = FALSE) {
*
* Check that the directory exists and is writable. Directories need to
* have execute permissions to be considered a directory by FTP servers, etc.
*
*
* @param $directory A string containing the name of a directory path.
* @param $mode A Boolean value to indicate if the directory should be created
......@@ -166,4 +173,14 @@ function field_file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
return TRUE;
}
/**
* Remove a possible leading file directory path from the given path.
*/
function field_file_strip_path($path) {
$dirpath = file_directory_path();
$dirlen = strlen($dirpath);
if (substr($path, 0, $dirlen + 1) == $dirpath .'/') {
$path = substr($path, $dirlen + 1);
}
return $path;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment