Unit Utils.IO

Uses
Classes, Interfaces, Objects and Records
Types
Constants
Variables

Description

Unit which has a set of functions for manipulating files and their contents. It has some functions for content search as well.

Overview

Functions and Procedures

function GetFileContent(const AFileName: string): string;
function GetJsonFileContentWithOutComments(const AFileName: string): string;
procedure SaveFileContent(const AFileName, AContent: string);
function FindInCodeFile(ACodeFile: TStringList; const AText: string): string;
function FindFile(const ACurrentDir, AFileName: string): string;
function FindProjectFile(const AProjectDir, AText: string): string;
function FindSourceFile(const AProjectDir: string): string;

Description

Functions and Procedures

function GetFileContent(const AFileName: string): string;

Get the contents of AFileName in string.

File name that will have its content returned )

function GetJsonFileContentWithOutComments(const AFileName: string): string;

Get the contents of a JSON AFileName in string. Remove commented lines to make possible do parse its content. Returns JSON content.

File name that will have its content returned )

procedure SaveFileContent(const AFileName, AContent: string);

Save AContent string in the provided file name.

Parameters
AFileName
Target file name, the file name will be replaced
AContent
Content string that will be saved on the file
function FindInCodeFile(ACodeFile: TStringList; const AText: string): string;

Returns first ocurrence of text in format line:1 (column is always 1). It is case insensitive search. If not text is found the function returns an empty string.

Parameters
ACodeFile
Should have have the file contents already loaded.
AText
The text to be found
function FindFile(const ACurrentDir, AFileName: string): string;

Recursively search for the first file from the specified path. Returns the filename with the full path if it was found.

Parameters
ACurrentDir
Folder from which to search including subfolders
AFileName
Name of the file to be searched
function FindProjectFile(const AProjectDir, AText: string): string;

From the current directory it tries to locate a lazarus project that contains a specific text. If AText is empty the first project found will be returned. Returns the project file name.

Parameters
ABuilder
Command builder of the main application that will be used to output user instructions or to iteract with the user.
function FindSourceFile(const AProjectDir: string): string;

From the current directory it tries to locate a source file. Any file with .pas or .pp extension will be considered as source file. Returns the first occurence of a source file. Returns empty if not source file was found.

Parameters
AProjectDir
Project path from which to search

Generated by PasDoc 0.16.0.