define('PREG_FIND_RECURSIVE', 1); define('PREG_FIND_DIRMATCH', 2); define('PREG_FIND_FULLPATH', 4); define('PREG_FIND_NEGATE', 8); define('PREG_FIND_DIRONLY', 16); define('PREG_FIND_RETURNASSOC', 32); define('PREG_FIND_SORTDESC', 64); define('PREG_FIND_SORTKEYS', 128); define('PREG_FIND_SORTBASENAME', 256); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTMODIFIED', 512); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTFILESIZE', 1024); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTDISKUSAGE', 2048); # requires PREG_FIND_RETURNASSOC // PREG_FIND_RECURSIVE - go into subdirectorys looking for more files // PREG_FIND_DIRMATCH - return directorys that match the pattern also // PREG_FIND_DIRONLY - return only directorys that match the pattern (no files) // PREG_FIND_FULLPATH - search for the pattern in the full path (dir+file) // PREG_FIND_NEGATE - return files that don't match the pattern // PREG_FIND_RETURNASSOC - Instead of just returning a plain array of matches, // return an associative array with file stats // // You can also request to have the results sorted based on various criteria // By default if any sorting is done, it will be sorted in ascending order. // You can reverse this via use of: // PREG_FIND_SORTDESC - Reverse order of sort // PREG_FILE_SORTKEYS - Sort on the keyvalues or non-assoc array results // The following sorts *require* PREG_FIND_RETURNASSOC to be used as they are // sorting on values stored in the constructed associative array // PREG_FIND_SORTBASENAME - Sort the results in alphabetical order on filename // PREG_FIND_SORTMODIFIED - Sort the results in last modified timestamp order // PREG_FIND_SORTFILESIZE - Sort the results based on filesize // PREG_FILE_SORTDISKUSAGE - Sort based on the amount of disk space taken // to use more than one simply seperate them with a | character // Search for files matching $pattern in $start_dir. // if args contains PREG_FIND_RECURSIVE then do a recursive search // return value is an associative array, the key of which is the path/file // and the value is the stat of the file. Function preg_find($pattern, $start_dir='.', $args=NULL) { static $depth = -1; ++$depth; $files_matched = array(); $fh = opendir($start_dir); while (($file = readdir($fh)) !== false) { if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue; $filepath = $start_dir . '/' . $file; if (preg_match($pattern, ($args & PREG_FIND_FULLPATH) ? $filepath : $file)) { $doadd = is_file($filepath) || (is_dir($filepath) && ($args & PREG_FIND_DIRMATCH)) || (is_dir($filepath) && ($args & PREG_FIND_DIRONLY)); if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) $doadd = false; if ($args & PREG_FIND_NEGATE) $doadd = !$doadd; if ($doadd) { if ($args & PREG_FIND_RETURNASSOC) { // return more than just the filenames $fileres = array(); if (function_exists('stat')) { $fileres['stat'] = stat($filepath); $fileres['du'] = $fileres['stat']['blocks'] * 512; } if (function_exists('fileowner')) $fileres['uid'] = fileowner($filepath); if (function_exists('filegroup')) $fileres['gid'] = filegroup($filepath); if (function_exists('filetype')) $fileres['filetype'] = filetype($filepath); if (function_exists('mime_content_type')) $fileres['mimetype'] = mime_content_type($filepath); if (function_exists('dirname')) $fileres['dirname'] = dirname($filepath); if (function_exists('basename')) $fileres['basename'] = basename($filepath); if (isset($fileres['uid']) && function_exists('posix_getpwuid')) $fileres['owner'] = posix_getpwuid ($fileres['uid']); $files_matched[$filepath] = $fileres; } else array_push($files_matched, $filepath); } } if ( is_dir($filepath) && ($args & PREG_FIND_RECURSIVE) ) { $files_matched = array_merge($files_matched, preg_find($pattern, $filepath, $args)); } } closedir($fh); // Before returning check if we need to sort the results. if (($depth==0) && ($args & (PREG_FIND_SORTKEYS|PREG_FIND_SORTBASENAME|PREG_FIND_SORTMODIFIED|PREG_FIND_SORTFILESIZE|PREG_FIND_SORTDISKUSAGE)) ) { $order = ($args & PREG_FIND_SORTDESC) ? 1 : -1; $sortby = ''; if ($args & PREG_FIND_RETURNASSOC) { if ($args & PREG_FIND_SORTMODIFIED) $sortby = "['stat']['mtime']"; if ($args & PREG_FIND_SORTBASENAME) $sortby = "['basename']"; if ($args & PREG_FIND_SORTFILESIZE) $sortby = "['stat']['size']"; if ($args & PREG_FIND_SORTDISKUSAGE) $sortby = "['du']"; } $filesort = create_function('$a,$b', "\$a1=\$a$sortby;\$b1=\$b$sortby; if (\$a1==\$b1) return 0; else return (\$a1<\$b1) ? $order : 0- $order;"); uasort($files_matched, $filesort); } --$depth; return $files_matched; } ?>
|
|---|
Modal verb - Modaal hulpwerkwoord
IntroductionThe modal verbs form a special category of Dutch verbs. They verbs are usually used with the infinitive of another verb to express ability or possibility (kunnen), obligation (moeten), permission (mogen) or volition (willen). The verb zullen (‘shall') can also be seen as a modal verb. However, it is dealt with separately under future aspect and modal verb: zou.
All modal verbs are irregular, but moeten is only irregular in the past tense and willen only in the present tense. Modal verbs can be used independently, i.e. without the infinitive of another verb. This happens normally only in spoken Dutch. However, in those cases, an infinitive can always be added.
When the infinitive of another verb is used along with the modal verb, the infinitive takes the last or penultimate place (see sentence structure) in the clause. < Top of page KunnenThe verb kunnen expresses ability or possibility, and can be translated with ‘to be able to' and ‘can'.
Kunnen is irregular in the present tense:
The choice between kan or kunt (for jij and u) is arbitrary and depends on personal or even contextual choice. However, some people consider kunt to be more formal than kan and will restrict the use of kan to spoken language. Top of page MoetenThe verb moeten expresses obligation, and can be translated with ‘to have to' or 'must'.
Top of page MogenThe verb mogen expresses permission, and can be translated with ‘to be allowed to' or ‘may'.
Mogen is irregular in the present tense:
Top of page WillenThe verb willen expresses volition, and can be translated with ‘to want to'. Note that willen cannot be translated with ‘will'.
Willen is irregular in the present tense:
The choice between wil or wilt (for jij and u) is arbitrary and depends on personal or even contextual choice. However, some people consider wilt to be more formal than wil and restrict the use of wil to spoken language. Top of page Perfect tense of modal verbsDutch has two different structures for modal verbs in the perfect tense, where English only has one. This is because it is possible to use Dutch modals independently, without an infinitive. In that case the perfect tense is made with the past participle of the modal verb (in red in every first sentence below; see also modals used independently). Some modal past participles are irregular (see also perfect tense). When the infinitive is used, the modal verb is not a past participle but an infinitive (underlined in every second sentence below; see also: auxiliaries). The perfect tense auxiliary with modal verbs is always hebben.
kunnen moeten mogen willen Note that zullen has no participle. For more information on the use of zullen, see modal verbs:zou. Top of page Past tense of modal verbsThe modal verbs kunnen, moeten and mogen are irregular in the past tense. (see also: irregular verbs in the past tense) kunnen
moeten
mogen
Top of page |