JX Application Framework
Loading...
Searching...
No Matches
Functions
jFileUtil.h File Reference
#include "JError.h"
#include "jTime.h"
#include <stdio.h>
#include "JString.h"
#include "jDirUtil.h"
Include dependency graph for jFileUtil.h:
This graph shows which files directly or indirectly include this file:

Functions

bool JFileExists (const JString &fileName)
 
bool JFileReadable (const JString &fileName)
 
bool JFileWritable (const JString &fileName)
 
bool JFileExecutable (const JString &fileName)
 
JError JGetFileLength (const JString &name, JSize *size)
 
JString JPrintFileSize (const JSize size)
 
JError JRenameFile (const JString &oldName, const JString &newName, const bool forceReplace=false)
 
JError JRemoveFile (const JString &fileName)
 
bool JKillFile (const JString &fileName)
 
JError JCreateTempFile (const JString *path, const JString *prefix, JString *fullName)
 
JError JUncompressFile (const JString &origFileName, JString *newFileName, const JString *dirName=nullptr, JProcess **process=nullptr)
 
JError JFOpen (const JString &fileName, const JUtf8Byte *mode, FILE **stream)
 
void JExtractFileAndLine (const JString &str, JString *fileName, JIndex *startLineIndex, JIndex *endLineIndex=nullptr)
 
JString JCombineRootAndSuffix (const JString &root, const JUtf8Byte *suffix)
 
JString JCombineRootAndSuffix (const JString &root, const JString &suffix)
 
bool JSplitRootAndSuffix (const JString &name, JString *root, JString *suffix)
 
JString JFileNameToURL (const JString &fileName)
 
bool JURLToFileName (const JString &url, JString *fileName)
 
JError JCreateTempFile (JString *fullName)
 

Function Documentation

◆ JCombineRootAndSuffix() [1/2]

JString JCombineRootAndSuffix ( const JString root,
const JString suffix 
)
inline

◆ JCombineRootAndSuffix() [2/2]

JString JCombineRootAndSuffix ( const JString root,
const JUtf8Byte suffix 
)

Combines the root and suffix with a period between them.

◆ JCreateTempFile() [1/2]

JError JCreateTempFile ( const JString path,
const JString prefix,
JString fullName 
)

Creates a unique file in the specified directory. If path is empty, it uses the system's scratch directory. If prefix is empty, uses temp_file_.

◆ JCreateTempFile() [2/2]

JError JCreateTempFile ( JString fullName)
inline

◆ JExtractFileAndLine()

void JExtractFileAndLine ( const JString str,
JString fileName,
JIndex startLineIndex,
JIndex endLineIndex = nullptr 
)

◆ JFileExecutable()

bool JFileExecutable ( const JString fileName)

Returns true if the specified file can be executed.

Readability is not checked, because this is only an issue for scripts, and I can't tell the difference between a script and a binary.

◆ JFileExists()

bool JFileExists ( const JString fileName)

Returns true if the specified file exists.

◆ JFileNameToURL()

JString JFileNameToURL ( const JString fileName)

JURLToFileName() does not accept URLs without a host name because the whole point of using URLs is that one doesn't know if the source and target machines will be the same.

◆ JFileReadable()

bool JFileReadable ( const JString fileName)

Returns true if the specified file can be read from.

◆ JFileWritable()

bool JFileWritable ( const JString fileName)

Returns true if the specified file can be written to.

◆ JFOpen()

JError JFOpen ( const JString fileName,
const JUtf8Byte mode,
FILE **  stream 
)

Wrapper for fopen() that returns JError.

◆ JGetFileLength()

JError JGetFileLength ( const JString name,
JSize size 
)

Sets *size to the the length of the specified file. Can return JDirEntryDoesNotExist.

◆ JKillFile()

bool JKillFile ( const JString fileName)

Tries as hard as it can to delete the file. Returns true if successful.

◆ JPrintFileSize()

JString JPrintFileSize ( const JSize  size)

Converts the given file size into a string with a reasonable precision. e.g. 1003280 -> 1MB

◆ JRemoveFile()

JError JRemoveFile ( const JString fileName)

◆ JRenameFile()

JError JRenameFile ( const JString oldName,
const JString newName,
const bool  forceReplace 
)

Renames the specified file.

◆ JSplitRootAndSuffix()

bool JSplitRootAndSuffix ( const JString name,
JString root,
JString suffix 
)

◆ JUncompressFile()

JError JUncompressFile ( const JString origFileName,
JString newFileName,
const JString dirName = nullptr,
JProcess **  process = nullptr 
)

◆ JURLToFileName()

bool JURLToFileName ( const JString url,
JString fileName 
)