Giter VIP home page Giter VIP logo

filefolder_utils's Introduction

FileFolder_Utils

A modern component that provides basic file and folder utility methods.

Features

  • Provides basic functionality for working with files and folders
  • Provides a set of methods to load files through a file buffer that adds additional abilities for retrieving the file contents from disk.

Requirements

  • 4D v18 is required.

Installation and Use

Copy the FileFolder_Utils.4dbase into the Components folder of your application. It is suggested that you compile the component before installing it into your own projects.

Examples

Example #1 - tbd

code here

Example #2 - tbd

code here

File / Folder Shared Methods

The methods provide a some basic functionality for working with files and folders.

File_DoesExist (pathToFile:c_text) returns doesExist:c_boolean

Returns true if the file exists. Any missing parent folders will be created if missing.

File_IsCSV (pathToFile:c_text) returns isCSV:c_boolean

Returns true if the file is a CSV. Recognizes a 1st line of of the csv file is a "sep=" line.

TESTS performed:

  • Is file extension ".csv" or ".txt"
  • Look at first line, expect line of comma separated values.
  • At least 2 non-empty values in the header line.

File_IsJPG (pathToFile:c_text) returns isJPG:c_boolean

Returns true if the image file is a JPG. The file extension is ignored, it looks at the image directly.

File_IsPNG (pathToFile:c_text) returns isPNG:c_boolean

Returns true if the image file is a PNG. The file extension is ignored, it looks at the image directly.

File_IsTabDelimited (pathToFile:c_text) returns isTabDelimited:c_boolean

Returns true if the file is tab-delimited.

TESTS performed:

  • Is file extension ".tsv" or ".txt"
  • Look at first line, expect line of tab-delimited values.
  • At least 2 non-empty values in the header line.

Folder_DoesExist (pathToFolder:c_text) returns doesExist:c_boolean

Returns true if the file exists.

Folder_ParentName (folderPath:c_text) returns parentFolderPath:c_text

Returns the parent folder of the folderPath passed in.

Folder_VerifyExistance (pathToFolder:c_text)

Creates a folder if it does not exist. If necessary, it will recursively create the parent folders as well.

FileBuffer Shared Methods

FileBuffer_Init (docRef:c_time {; bufferSize:c_longint})

Initializes the necessary vars and pre-fills the buffer from the already opened file.

FileBuffer_TellMeTheEOL () returns theEol:C_text

Scans the filebuffer to figure out what the EOL is.

FileBuffer_EOF () returns isEOF:C_boolean

Returns true if we are at the end of file.

FileBuffer_GetFilePostion () returns currentPositionInFile:c_longint

Returns a logical position in the file.

FileBuffer_FetchData_BySize (numBytesToFetch:c_longint) returns fileContent:c_text

This method returns the specified number of bytes. If it cannot then that means that the file is empty.

FileBuffer_FetchData_ByString (matchOnText:c_text{; matchOnText2:c_text}) returns fileContent:c_text

Returns text from the buffer up to AND INCLUDING the matchOnText or matchOnText2 values.

NOTE: This differs from RECEIVE PACKET.

FileBuffer_FetchData_PeekAhead (numCharactersToReturn:c_longint) returns fileContent:c_text

Returns fileContent up to the number of characters specified without advancing the current position in the file.

FileBuffer_FetchCSVLine (eol:C_text , valuesArrPtr:C_pointer)

Populates the array with the parsed values from the line. Recognizes a 1st line of "sep=" line.

FileBuffer_FetchTabDelimitedLne (eol:C_text , valuesArrPtr:C_pointer)

Fills the array with the next line of tab delimited values from the open file.

filefolder_utils's People

Contributors

dbeaubien avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

b-hal timyounes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.