{@inheritDoc}

- extra: Holds a list (array) of files and their in formation (mime-icon,
file name, etc).

- value: Holds a text containing all file names separated by space.
13002
public function beforeSave(Field $field, $post)
    {
        // FIX Removes the "dummy" input from extra if exists, the "dummy" input is
        // used to force Field Handler to work when empty POST information is sent
        $extra = [];
        foreach ((array)$field->extra as $k => $v) {
            if (is_integer($k)) {
                $extra[] = $v;
            }
        }
        $field->set('extra', $extra);

        $files = (array)$post;
        if (!empty($files)) {
            $value = [];
            foreach ($files as $k => $file) {
                if (!is_integer($k)) {
                    unset($files[$k]);
                    continue;
                } else {
                    $file = array_merge([
                        'mime_icon' => '',
                        'file_name' => '',
                        'file_size' => '',
                        'description' => '',
                    ], (array)$file);
                }
                $value[] = trim("{$file['file_name']} {$file['description']}");
            }
            $field->set('value', implode(' ', $value));
            $field->set('extra', $files);
        }

        if ($field->metadata->value_id) {
            $newFileNames = Hash::extract($files, '{n}.file_name');

            try {
                $prevFiles = (array)TableRegistry::get('Eav.EavValues')
                    ->get($field->metadata->value_id)
                    ->extra;
            } catch (\Exception $ex) {
                $prevFiles = [];
            }

            foreach ($prevFiles as $f) {
                if (!in_array($f['file_name'], $newFileNames)) {
                    $file = normalizePath(WWW_ROOT . "/files/{$field->metadata->settings['upload_folder']}/{$f['file_name']}", DS);
                    $file = new File($file);
                    $file->delete();
                }
            }
        }

        return true;
    }
683962
private function neglectVendorFiles($filesByFile)
    {
        $return = [];

        foreach ($filesByFile->toArray() as $key => $value) {
            if (! Str::contains($key, ':')) {
                $return[$key] = $value;
            }
        }

        return $return;
    }
457141
function globsToExcludeFromFileSet (dirname, fileset) {
  if (fileset.excludes && fileset.excludes.length) {
    return fileset.excludes.map(exclude => '!' + path.join(dirname, exclude));
  } else {
    return [];
  }
}
787217
function (dir, filelist, ext, currentBundleOptions) {
    var path = path || require('path');
    var fs = fs || require('fs');
    var files = fs.readdirSync(dir);
    filelist = filelist || [];
    files.forEach(function (file) {
        if (fs.statSync(path.join(dir, file)).isDirectory()) {
            filelist = walkSync(path.join(dir, file), filelist, ext, currentBundleOptions);
        }
        else {
            if (file.match(new RegExp("." + ext + "$")) && !isExcluded(file, currentBundleOptions))
                filelist.push(path.join(dir, file));
        }
    });
    return filelist;
}
1011746
public Article putExtra(String key, String value) {
		this.extras.putString(key, value);
		return this;
	}
671110
public static @NotNull String validFilename(@NotNull String value) {
    String fileExtension = StringUtils.substringAfterLast(value, ".");
    String fileName = StringUtils.substringBeforeLast(value, ".");
    if (StringUtils.isEmpty(fileExtension)) {
      return validName(fileName);
    }
    return validName(fileName) + "." + validName(fileExtension);
  }
261922
private static function _formatFilePath($filename, $format, $extras = array(), $addHostname = false)
    {
        // we can parse scalars also
        if(is_scalar($extras)) {
            $extras = array($extras);
        }

        if(!is_array($extras)) {
            throw new \Exception('Extras parameter must be array');
        }

        $dot_pos  = strrpos($filename, '.');
        if(!$dot_pos) {
            $filename .= '.log';
            $dot_pos  = strrpos($filename, '.');
        }

        $tmp = strlen($filename) - $dot_pos;

        switch ($format) {
            case self::LOGPATH_FORMAT_COMPLEX:
                // add short date and 24 hour format as last parama
                $extras[] = $addHostname
                    ? substr($filename, 0, $dot_pos) . '_' . gethostname()
                    : substr($filename, 0, $dot_pos);
                $extras = array_merge($extras, explode('-', date("H-d-m-Y", Tools::ts())));
                // reverse order or extras array so that year is first, month etc...
                $extras = array_reverse($extras);
                $glue = DIRECTORY_SEPARATOR;
                break;

            default:
            case self::LOGPATH_FORMAT_SIMPLE:
                // add machine hostname to extra array
                $extras[] = substr($filename, 0, $dot_pos);
                if($addHostname) {
                    $extras[] = gethostname();
                }
                $extras[] = date("Y-m-d", Tools::ts());
                $glue = '_';
                break;
        }

        return implode($glue, $extras) . substr($filename,  "-{$tmp}", $tmp);
    }
781308
def multipart_content(*files):
    
    outer = MIMEMultipart()
    for fname in files:
        mtype = get_type(fname)
        maintype, subtype = mtype.split('/', 1)
        with open(fname) as f:
            msg = MIMEText(f.read(), _subtype=subtype)
        msg.add_header('Content-Disposition', 'attachment', 
                       filename=os.path.basename(fname))
        outer.attach(msg)
    return outer.as_string()
21859
def splitext(path):
    """"""
    li = []
    path_without_extensions = os.path.join(os.path.dirname(path),
        os.path.basename(path).split(os.extsep)[0])
    extensions = os.path.basename(path).split(os.extsep)[1:]
    li.append(path_without_extensions)
    # li.append(extensions) if you want extensions in another list inside the list that is returned.
    li.extend(extensions)
    return li
1257067
function getExtensionlessFilename( filename ) {
	return filename.substr( 0, filename.length - path.extname( filename ).length);
}
162766
def _bin_to_extra(extra_bytes):
  
  #global _bam_value_type
  extra = StringIO(extra_bytes)
  tags = {}
  rem = ''
  while extra.tell() < len(extra_bytes):
    tag = extra.read(2)
    val_type = extra.read(1)
    if val_type == 'Z':
      rem += tag+':'
      rem += val_type+':'
      p = re.compile('([!-~])')
      m = p.match(extra.read(1))
      vre = ''
      while m:
        vre += m.group(1)
        c = extra.read(1)
        #print c
        m = p.match(c)
      rem += vre+"\t"
      tags[tag] = TagDatum(val_type, vre)
      #tags[tag] = {'type':val_type,'value':vre}
    elif val_type == 'A':
      rem += tag+':'
      rem += val_type+':'
      vre = extra.read(1)
      rem += vre+"\t"      
      tags[tag] = TagDatum(val_type, vre)
      #tags[tag] = {'type':val_type,'value':vre}      
    elif val_type in _bam_value_type:
      rem += tag+':'
      rem += 'i'+':'
      val = struct.unpack(_bam_value_type[val_type][1],extra.read(_bam_value_type[val_type][0]))[0]
      rem += str(val)+"\t"
      tags[tag] = TagDatum(val_type, val)
      #tags[tag] = {'type':val_type,'value':val}
    elif val_type == 'B':
      sys.sterr.write("WARNING array not implmented\n")
      continue
      rem += tag+':'
      rem += val_type+':'
      array_type = _bam_value_type[extra.read(1)]
      element_count = struct.unpack('<I',extra.read(4))[0]
      array_bytes = extra.read(element_count*_bam_value_type[array_type][0])
      for by in [array_bytes[i:i+_bam_value_type[array_type][0]] for i in range(0,len(array_bytes),_bam_value_type[array_type][0])]:
        aval = struct.unpack(_bam_value_type[array_type][1],by)
  return [tags,rem.rstrip("\t")]
1325312
function extras(src, js, options) {
		if (options.superword) {
			js = suber.pseudokeyword(
				js,
				getwords(options.superword, defaultoptions.superword),
				getwords(options.classword, defaultoptions.classword)
			);
		}
		return js;
	}
1340154
private static List<Media> getFilesByExtension(Media path, String extension)
    {
        final List<Media> filesList = new ArrayList<>(1);
        getFilesByExtensionRecursive(filesList, path, extension);
        return filesList;
    }
375878
def extensions(self):
        
        _tmp_extensions = self.mimes.encodings_map.keys() + \
            self.mimes.suffix_map.keys() + \
            self.mimes.types_map[1].keys() + \
            cfg['CFG_BIBDOCFILE_ADDITIONAL_KNOWN_FILE_EXTENSIONS']
        extensions = []
        for ext in _tmp_extensions:
            if ext.startswith('.'):
                extensions.append(ext)
            else:
                extensions.append('.' + ext)
        extensions.sort()
        extensions.reverse()
        extensions = set([ext.lower() for ext in extensions])
        extensions = '\\' + '$|\\'.join(extensions) + '$'
        extensions = extensions.replace('+', '\\+')
        return re.compile(extensions, re.I)
58165
public synchronized void addExtra(String name, Object value) {
        if (extra == null) {
            extra = new HashMap<>();
        }

        extra.put(name, value);
    }
816383
public static String fileExtensionForMIMEType(String mimeType) {
        loadMappings();

        String ext = mimeTypeToExtensionMap.get(mimeType);

        if (ext == null) ext = "dat";

        return ext;
    }
1053272
private boolean contentsExcluded(String name) {
        name = (name.endsWith(File.separator)) ? name : name + File.separator;
        for (int i = 0; i < excludes.length; i++) {
            String e = excludes[i];
            if (e.endsWith("**") && SelectorUtils.matchPath(
                e.substring(0, e.length() - 2), name, isCaseSensitive())) {
                return true;
            }
        }
        return false;
    }