FAKE - F# Make


FileHelper

Contains helper function which allow to deal with files and directories.

Functions and values

Function or valueDescription
allFiles path
Signature: path:string -> bool

Includes all files

AppendTextFiles newFileName files
Signature: newFileName:string -> files:seq<string> -> unit

Appends all given files to one file.

Parameters

  • newFileName - The target FileName.
  • files - The original FileNames as a sequence.
changeExt extension fileName
Signature: extension:string -> fileName:string -> string

Change the extension of the file.

Parameters

  • 'extension' - The new extension containing the leading '.'.
  • 'fileName' - Name of the file from which the extension is retrieved.
CleanDir path
Signature: path:string -> unit

Cleans a directory by removing all files and sub-directories.

CleanDirs dirs
Signature: dirs:seq<string> -> unit

Cleans multiple directories

CompareFiles (...)
Signature: delete:bool -> originalFileName:string -> compareFileName:string -> bool

Compares the given files for changes. If delete is set to true then equal files will be removed.

Copy target files
Signature: target:string -> files:seq<string> -> unit

Copies the files to the target.

Parameters

  • target - The target directory.
  • files - The original file names as a sequence.
CopyCached target cacheDir files
Signature: target:string -> cacheDir:string -> files:seq<string> -> string list

Copies the files from a cache folder. If the files are not cached or the original files have a different write time the cache will be refreshed.

Parameters

  • target - The target FileName.
  • cacheDir - The cache directory.
  • files - The orginal files.
CopyDir target source filterFile
Signature: target:string -> source:string -> filterFile:(string -> bool) -> unit

Copies a directory recursivly. If the target directory does not exist, it will be created.

Parameters

  • target - The target directory.
  • source - The source directory.
  • filterFile - A file filter predicate.
CopyFile target fileName
Signature: target:string -> fileName:string -> unit

Copies a single file to the target and overwrites the existing file.

Parameters

  • target - The target directory or file.
  • fileName - The FileName.
CopyFileIntoSubFolder target fileName
Signature: target:string -> fileName:string -> unit

Copies a single file to a relative subfolder of the target.

Parameters

  • target - The target directory
  • fileName - The fileName
CopyFiles target files
Signature: target:string -> files:seq<string> -> unit

Copies the files to the target - Alias for Copy

Parameters

  • target - The target directory.
  • files - The orginal file names.
CopyFileWithSubfolder (...)
Signature: baseDir:string -> target:string -> fileName:string -> unit

Copies a single file to the target folder preserving the folder structure starting from the specified base folder.

Parameters

  • baseDir - The base directory.
  • target - The target directory.
  • fileName - The file name.
copyRecursive dir outputDir overwrite
Signature: dir:DirectoryInfo -> outputDir:DirectoryInfo -> overwrite:bool -> string list

Copies the file structure recursively.

CopyRecursive dir outputDir
Signature: dir:string -> outputDir:string -> bool -> string list

Copies the file structure recursively.

CopyTo target files
Signature: target:string -> files:seq<string> -> unit

Copies the given files to the target.

Parameters

  • target - The target directory.
  • files - The original file names as a sequence.
CopyWithSubfoldersTo target files
Signature: target:string -> files:seq<FileIncludes> -> unit

Copies several file groups, each represented by a FileIncludes object, to the target folder preserving the folder structure starting from the BaseDirectory of each FileIncludes.

Parameters

  • target - The target directory.
  • files - A sequence of file groups.
CreateDir path
Signature: path:string -> unit

Creates a directory if it does not exist.

CreateFile fileName
Signature: fileName:string -> unit

Creates a file if it does not exist.

DeleteDir path
Signature: path:string -> unit

Deletes a directory if it exists.

DeleteDirs dirs
Signature: dirs:seq<string> -> unit

Deletes multiple directories

DeleteFile fileName
Signature: fileName:string -> unit

Deletes a file if it exists.

DeleteFiles files
Signature: files:seq<string> -> unit

Deletes the given files.

directory path
Signature: path:string -> string

Get the directory of the specified path

Parameters

  • 'path' - The path from which the directory is retrieved.
excludeSVNFiles path
Signature: path:string -> bool

Exclude SVN files (path with .svn)

ext fileName
Signature: fileName:string -> string

Get the filename extension including the leading '.', or an empty string if the file has no extension.

Parameters

  • 'fileName' - Name of the file from which the extension is retrieved.
filename path
Signature: path:string -> string

Get the filename for the specified path

Parameters

  • 'path' - The path from which the filename is retrieved.
filenameWithouExt path
Signature: path:string -> string
fileNameWithoutExt path
Signature: path:string -> string

Get the filename for the specified path without it's extension

Parameters

  • 'path' - The path from which the filename is retrieved.
FilesAreEqual first second
Signature: first:FileInfo -> second:FileInfo -> bool

Checks if the two files are byte-to-byte equal.

FileVersion fileName
Signature: fileName:string -> string

Get the version a file.

Parameters

  • 'fileName' - Name of file from which the version is retrieved. The path can be relative.
GeneratePatch (...)
Signature: lastReleaseDir:string -> patchDir:string -> srcFiles:seq<string> -> unit

Checks the srcFiles for changes to the last release.

Parameters

  • lastReleaseDir - The directory of the last release.
  • patchDir - The target directory.
  • srcFiles - The source files.
GeneratePatchWithFindOldFileFunction (...)
Signature: lastReleaseDir:string -> patchDir:string -> srcFiles:seq<string> -> findOldFileF:(string -> string -> string) -> unit

Checks the srcFiles for changes to the last release.

Parameters

  • lastReleaseDir - The directory of the last release
  • patchDir - The target directory
  • srcFiles - The source files
  • findOldFileF - A function which finds the old file
hasExt extension fileName
Signature: extension:string -> fileName:string -> bool

Tests whether the file has specified extensions (containing the leading '.')

Parameters

  • 'extension' - The extension to fine containing the leading '.'.
  • 'fileName' - Name of the file from which the extension is retrieved.
MoveFile target fileName
Signature: target:string -> fileName:string -> unit

Moves a single file to the target and overwrites the existing file.

Parameters

  • target - The target directory.
  • fileName - The FileName.
ReadCSVFile file
Signature: file:string -> seq<string []>

Reads a csv file line by line delimiter is a ,

recursively dirF fileF dir
Signature: dirF:(DirectoryInfo -> unit) -> fileF:(FileInfo -> unit) -> dir:DirectoryInfo -> unit

Performs the given actions on all files and subdirectories

RegexReplaceInFilesWithEncoding (...)
Signature: pattern:string -> replacement:string -> encoding:Encoding -> files:seq<string> -> unit

Replace all occurences of the regex pattern with the given replacement in the specified files

Parameters

  • pattern - The string to search for a match
  • replacement - The replacement string
  • encoding - The encoding to use when reading and writing the files
  • files - The paths of the files to process
RegexReplaceInFileWithEncoding (...)
Signature: pattern:string -> replacement:string -> encoding:Encoding -> file:string -> unit

Replace all occurences of the regex pattern with the given replacement in the specified file

Parameters

  • pattern - The string to search for a match
  • replacement - The replacement string
  • encoding - The encoding to use when reading and writing the file
  • file - The path of the file to process
Rename target fileName
Signature: target:string -> fileName:string -> unit

Renames the file or directory to the target name.

Parameters

  • target - The target file or directory name.
  • fileName - The orginal file or directory name.
ReplaceInFiles replacements files
Signature: replacements:seq<string * string> -> files:seq<string> -> unit

Replaces all occurences of the patterns in the given files with the given replacements.

Parameters

  • replacements - A sequence of tuples with the patterns and the replacements.
  • files - The files to process.
setDirectoryReadOnly readOnly dir
Signature: readOnly:bool -> dir:DirectoryInfo -> unit

Sets the directory readonly

SetDirReadOnly readOnly dir
Signature: readOnly:bool -> dir:DirectoryInfo -> unit

Sets all files in the directory readonly.

SetReadOnly readOnly files
Signature: readOnly:bool -> files:seq<string> -> unit

Sets all given files readonly.

SilentCopy target files
Signature: target:string -> files:seq<string> -> unit

Copies a list of files to the specified directory without any output.

Parameters

  • target - The target directory.
  • files - List of files to copy.
TestDir path
Signature: path:string -> bool

Checks if the directory exists

TestFile path
Signature: path:string -> bool

Checks if the file exists

WriteConfigFile (...)
Signature: configFileName:string -> parameters:seq<'?11875 * '?11876> -> unit
Type parameters: '?11875, '?11876

Creates a config file with the parameters as "key;value" lines

Active patterns

Active patternDescription
( |EndsWith|_| ) extension file
Signature: extension:string -> file:string -> unit option

Active Pattern for determining file extension.

( |File|Directory| ) fileSysInfo
Signature: fileSysInfo:FileSystemInfo -> Choice<FileInfo,(DirectoryInfo * IEnumerable<FileSystemInfo>)>

Active pattern which discriminates between files and directories.

( |FileInfoFullName| ) f
Signature: f:FileInfo -> string

Active Pattern for determining file name.

( |FileInfoNameSections| ) f
Signature: f:FileInfo -> string * string * string

Active Pattern for determining FileInfoNameSections.

Fork me on GitHub