Functions
File Functions

Functions

int mdlFile_create (BeFileNameP outname, WCharCP inname, WCharCP envvar, WCharCP iext)
 Gets the full file path for a file that an application may then want to create. More...
 
int mdlFile_find (BeFileNameP outname, WCharCP inname, WCharCP envvar, WCharCP iext, FINDFILE_Options options=FINDFILEOPTION_Default)
 Finds the full path for an existing file. More...
 
int mdlFile_findFiles (FindFileInfo **out, int *nFiles, WCharCP spec, int attributeFilter)
 Collects information on files matching the specifications provided. More...
 
int mdlFile_getDrive (int *drive)
 Returns the current default drive number. More...
 
int mdlFile_getFileAttributes (int *attributes, WCharCP fileName)
 Gets the attributes of the specified file. More...
 
int mdlFile_setDefaultShare (int shareFlag)
 Sets a file sharing mode used by fopen when opening a file for the MDL task. More...
 
int mdlFile_setDrive (int *logicalDrives, int drive)
 Establishes a new default drive for file system operations. More...
 
bool mdlFile_isSameFile (WCharCP fileName1, WCharCP fileName2, DgnPlatform::FileCompareMask compareMask)
 Check if two fully qualified file-names represent the same physical file. More...
 
int mdlFile_mkdir (WCharCP dirPath)
 Creates the new directory specified. More...
 
bool mdlFile_isUntitledDesign (WCharCP dgnFileName)
 Determines whether the file name represents an untitled file. More...
 
bool mdlFile_validDesignFile (bool *pThreeD, DgnPlatform::DgnFileFormatType *pFormat, int *pMajorVersion, int *pMinorVersion, byte **ppThumbnail, int *pThumbnailSize, WCharCP pFileName)
 Tests whether the specified file is a valid MicroStation design file. More...
 
int mdlFile_copy (WCharCP destinationFile, WCharCP sourceFile)
 Copies a file. More...
 
BeFileNameStatus mdlFile_delete (WCharCP filePath)
 Deletes/removes a file. More...
 
bool mdlFile_isValidDrive (WCharCP drive)
 Checks to see if a drive is valid. More...
 
int mdlFile_getDiskFree (UInt64 *space, int drive)
 Gets the number of free bytes on a file system. More...
 
int mdlFile_createDeprecated (WCharP outname, WCharCP inname, WCharCP envvar, WCharCP iext)
 Gets the full file path for a file that an application may then want to create. More...
 
int mdlFile_findDeprecated (WCharP outname, WCharCP inname, WCharCP envvar, WCharCP iext)
 Finds the full path for an existing file. More...
 
int mdlFile_findExtDeprecated (WCharP outname, WCharCP inname, WCharCP envvar, WCharCP iext, FINDFILE_Options options)
 Finds the full path for an existing file. More...
 

Detailed Description

Function Documentation

int mdlFile_copy ( WCharCP  destinationFile,
WCharCP  sourceFile 
)

Copies a file.

Parameters
[in]destinationFilename of destination file
[in]sourceFilename of source file
Returns
returns SUCCESS if the file is successfully copied. Otherwise, it returns a non-zero value.
Remarks
If the file specified by destinationFile does not exist before the call, mdlFile_copy creates it. If it does exist before the call, mdlFile_copy overwrites it.
int mdlFile_create ( BeFileNameP  outname,
WCharCP  inname,
WCharCP  envvar,
WCharCP  iext 
)

Gets the full file path for a file that an application may then want to create.

The file path is based on the names provided in inname, envvar and iext. outname. If a file with that name exists before the call, the file is deleted. This method is preferred over the variant with a WCharP output as it can accomodate arbitrary sized file names.

Parameters
[out]outnamea BeFileName object buffer to receive the full filename. outnameP can be NULL if mdlFile_find is being used to check to see whether such a file can be created.
[in]innamea filename that has a format a user would enter. It can contain a logical filename and a path. It can contain an extension. The information in innameP is used first to find the file.
[in]envvarusually provides the name of an environment variable. The information in the environment variable generally provides a list of paths to examine when searching for the file. It can be NULL.
[in]iextusually provides a file extension (example .dgn). ext can be NULL.
Returns
SUCCESS if a valid file could be created. If so, and outname is not NULL, it contains a valid file path. Otherwise, the value in outnamep is invalid.
See also
mdlFile_parseName mdlFile_find
int mdlFile_createDeprecated ( WCharP  outname,
WCharCP  inname,
WCharCP  envvar,
WCharCP  iext 
)

Gets the full file path for a file that an application may then want to create.

The file path is based on the names provided in inname, envvar and iext. outname. If a file with that name exists before the call, the file is deleted. This BeFileName variant below is preferred as it can accept arbitrarily large file names.

Parameters
[out]outnamea buffer to receive the full filename. The size of the buffer must be at least MAXFILELENGTH bytes. outnameP can be NULL if mdlFile_find is being used to check to see whether such a file can be created.
[in]innamea filename that has a format a user would enter. It can contain a logical filename and a path. It can contain an extension. The information in innameP is used first to find the file.
[in]envvarusually provides the name of an environment variable. The information in the environment variable generally provides a list of paths to examine when searching for the file. It can be NULL.
[in]iextusually provides a file extension (example .dgn). ext can be NULL.
Returns
SUCCESS if a valid file could be created. If so, and outname is not NULL, it contains a valid file path. Otherwise, the value in outnamep is invalid.
See also
mdlFile_parseName mdlFile_find
BeFileNameStatus mdlFile_delete ( WCharCP  filePath)

Deletes/removes a file.

Parameters
[in]filePathname of file
Returns
returns SUCCESS if the file is successfully deleted. Otherwise, it returns a non-zero value.
int mdlFile_find ( BeFileNameP  outname,
WCharCP  inname,
WCharCP  envvar,
WCharCP  iext,
FINDFILE_Options  options = FINDFILEOPTION_Default 
)

Finds the full path for an existing file.

The file path is based on the names provided in inname, envvar, and iext.

Parameters
[out]outnamepoints BeFileName to recieve the file name
[in]innamea filename that has a format a user would enter. It can contain a logical filename and a path. It can contain an extension. The information in inname is used first to find the file.
[in]envvarusually provides the name of an environment variable. The information in the environment variable generally provides a list of paths to examine when searching for the file. It can be NULL.
[in]iextusually provides a file extension (example .dgn). ext can be NULL.
[in]optionsAn OR of the options in FDFILE_Options. See Remarks below.
Remarks
Normally, mdlFindFile checks the current working directory (see getcwd) for the file first. If FINDFILEOPTION_CurrentDirectoryLast is OR'ed into the options argument, it checks the current directory last. If FINDFILEOPTION_SkipCurrntDir is OR'ed into the options, it doesn't look in the current working directory at all (which means that a directory must be supplied in one of the other arguments).
Returns
SUCCESS if it finds the file. Otherwise, it returns a non-zero value. If mdlFile_find returns SUCCESS and outnameP is not NULL, the buffer that outname points to receives the full file specification. If mdlFile_find returns an error, and outnameP is not NULL, the buffer that outname points to receives the full file specification of the last place mdlFile_findExt looked.
See also
mdlFile_parseName mdlFile_create
int mdlFile_findDeprecated ( WCharP  outname,
WCharCP  inname,
WCharCP  envvar,
WCharCP  iext 
)

Finds the full path for an existing file.

The file path is based on the names provided in inname, envvar, and iext.

Parameters
[out]outnamepoints to a buffer to receive the full filename. The size of the buffer must be at least MAXFILELENGTH bytes. outname can be NULL if mdlFile_find is being used to check for the existence of a file.
[in]innamea filename that has a format a user would enter. It can contain a logical filename and a path. It can contain an extension. The information in inname is used first to find the file.
[in]envvarusually provides the name of an environment variable. The information in the environment variable generally provides a list of paths to examine when searching for the file. It can be NULL.
[in]iextusually provides a file extension (example .dgn). ext can be NULL.
Returns
SUCCESS if it finds the file. Otherwise, it returns a non-zero value. If mdlFile_find returns SUCCESS and outnameP is not NULL, the buffer that outname points to receives the full file specification. If mdlFile_find returns an error, and outnameP is not NULL, the buffer that outname points to receives the full file specification of the last place mdlFile_findExt looked.
See also
mdlFile_parseName mdlFile_create
int mdlFile_findExtDeprecated ( WCharP  outname,
WCharCP  inname,
WCharCP  envvar,
WCharCP  iext,
FINDFILE_Options  options 
)

Finds the full path for an existing file.

The file path is based on the names provided in inname, envvar, and iext.

Parameters
[out]outnamepoints to a buffer to receive the full filename. The size of the buffer must be at least MAXFILELENGTH bytes. outname can be NULL if mdlFile_find is being used to check for the existence of a file.
[in]innamea filename that has a format a user would enter. It can contain a logical filename and a path. It can contain an extension. The information in inname is used first to find the file.
[in]envvarusually provides the name of an environment variable. The information in the environment variable generally provides a list of paths to examine when searching for the file. It can be NULL.
[in]iextusually provides a file extension (example .dgn). ext can be NULL.
[in]optionsAn OR of the options in FDFILE_Options. See Remarks below.
Remarks
Normally, mdlFindFile checks the current working directory (see getcwd) for the file first. If FINDFILEOPTION_CurrentDirectoryLast is OR'ed into the options argument, it checks the current directory last. If FINDFILEOPTION_SkipCurrntDir is OR'ed into the options, it doesn't look in the current working directory at all (which means that a directory must be supplied in one of the other arguments).
Returns
SUCCESS if it finds the file. Otherwise, it returns a non-zero value. If mdlFile_find returns SUCCESS and outnameP is not NULL, the buffer that outname points to receives the full file specification. If mdlFile_find returns an error, and outnameP is not NULL, the buffer that outname points to receives the full file specification of the last place mdlFile_findExt looked.
See also
mdlFile_parseName mdlFile_create
int mdlFile_findFiles ( FindFileInfo **  out,
int *  nFiles,
WCharCP  spec,
int  attributeFilter 
)

Collects information on files matching the specifications provided.

Information on files and directories can be obtained.

Parameters
[out]outpointer to an array of FindFileInfo structures.
[out]nFilespointer to the count of the number of entries in the array of FindFileInfo structures.
[in]specfile specification for the requested files or directories. It is an expression that consists of any combination of constant characters and the special wild card characters ? and *. The wild card characters are expanded by mdlFile_findFiles exactly as the operating system expands these pattern-matching characters in interactive key-ins. The wild card character ? matches any single character and the wild card character * matches any sequence of characters.
[in]attributeFilteris set to any of the following constants, which can be combined with the bitwise OR operator "|":
  • FF_NORMAL for normal files
  • FF_READONLY for read only files
  • FF_SUBDIR for subdirectories
Returns
SUCCESS if no errors occurred, or MDLERR_INSFMEMORY if memory could not be allocated for the array of FindFileInfo structures.
Remarks
mdlFile_findFiles allocates the memory to hold an array of FindFileInfo structures using the malloc function. Each entry in the array describes a file or directory matching the specifications.
When the information is no longer needed, the MDL application must call free to free the memory pointed to by *fileInfoP.
int mdlFile_getDiskFree ( UInt64 space,
int  drive 
)

Gets the number of free bytes on a file system.

Parameters
[out]spacethe number of free bytes available on fileSystem.
[in]drivethe file system to examine for free storage. 0 means the "current" drive, 1 means A:, 2 means B:, etc.
Returns
SUCCESS or a non-zero error code.
int mdlFile_getDrive ( int *  drive)

Returns the current default drive number.

Parameters
[out]drivethe default drive. It is an integer corresponding to the drive number, where drive A: is 1, drive B: is 2, and so on.
Returns
SUCCESS if able to get the current drive, or ERROR.
See also
mdlFile_setDrive
int mdlFile_getFileAttributes ( int *  attributes,
WCharCP  fileName 
)

Gets the attributes of the specified file.

Parameters
[out]attributesattributes of file or directory
[in]fileNamepoints to a string specifying either a complete directory path or complete file name specification.
Returns
SUCCESS if it finds the directory or file. Otherwise, it returns a non-zero error code.
See also
mdlFile_find
bool mdlFile_isSameFile ( WCharCP  fileName1,
WCharCP  fileName2,
DgnPlatform::FileCompareMask  compareMask 
)

Check if two fully qualified file-names represent the same physical file.

Parameters
[in]fileName1fully qualified name of first file
[in]fileName2fully qualified name of second file
[in]compareMaskmask which controls degree of comparison
Remarks
The parameter compareMask is "OR'ed mask of one or more of the possible values (defined in msdefs.h):
FileCompareMask::BaseNameAndExtension
Check if base-name and extension are different. Set this if you wish to conclude that different base-name and extension represent different files. If different then return value is false.
FileCompareMask::FileStat
Check if file-stats are different. If different then return value is false.
FileCompareMask::All
Do all the checks
If the fully qualified names are the same, then the function will alway return that the file-names represent the same file
Returns
true if the two files represent the same file, else false
bool mdlFile_isUntitledDesign ( WCharCP  dgnFileName)

Determines whether the file name represents an untitled file.

Parameters
[in]dgnFileNamethe file name to check.
Returns
true if dgnFileNameP is the name of an untitled file.
See also
mdlSystem_saveDesignFile mdlSystem_newDesignFile
bool mdlFile_isValidDrive ( WCharCP  drive)

Checks to see if a drive is valid.

Parameters
[in]drivespecifies a drive and must be terminated by a path separator.
Returns
TRUE if drive is a valid drive.
int mdlFile_mkdir ( WCharCP  dirPath)

Creates the new directory specified.

Unlike the standard C function mkdir, mdlFile_mkdir creates the path to the resulting directory if it doesn't already exist.

Parameters
[in]dirPathdirectory path
Returns
SUCCESS if successful, or nonzero if the path and/or directory were not created. The nonzero values correspond to those returned by the implementation of mkdir on the platform being used.
Remarks
An example of dirPath would be "d:\d1\d2\d3\d4".
int mdlFile_setDefaultShare ( int  shareFlag)

Sets a file sharing mode used by fopen when opening a file for the MDL task.

Parameters
[in]shareFlagmay be MDL_SHARE_COMPATIBILITY, MDL_SHARE_DENY_READ_WRITE, MDL_SHARE_DENY_WRITE, MDL_SHARE_DENY_READ or MDL_SHARE_DENY_NONE. By default, MDL_SHARE_DENY_NONE is used.
Returns
the previous file sharing mode.
Remarks
The effect of the sharing mode flags is as follows:
MDL_SHARE_COMPATIBILITY allows unlimited access to the file from the same machine. Programs running on other machines cannot access the file while it is open unless the file has the read-only attribute. Any attempt to open the file in compatibility mode fails if the file has already been opened with any other sharing mode.
MDL_SHARE_DENY_READ_WRITE provides exclusive access to the file. Any subsequent attempts to open the file fail. This mode fails if the file has already been opened in any mode other than MDL_SHARE_COMPATIBILITY mode.
MDL_SHARE_DENY_WRITE permits subsequent opens for read-only access. This mode fails if the file has already been opened with MDL_SHARE_COMPATIBILITY or MDL_SHARE_DENY_WRITE mode.
MDL_SHARE_DENY_READ permits subsequent opens for write-only access. This mode fails if the file has already been opened with MDL_SHARE_COMPATIBILITY or MDL_SHARE_DENY_READ mode.
MDL_SHARE_DENY_NONE is similar to MDL_SHARE_COMPATIBILITY, but it does not allow the file to be opened in compatibility mode. This mode fails if the file has already been opened in compatibility mode.
int mdlFile_setDrive ( int *  logicalDrives,
int  drive 
)

Establishes a new default drive for file system operations.

Performing an mdlFile_setDrive has the same effect as interactively changing the default drive with a drive letter key-in such as A:.

Parameters
[out]logicalDrivesreceives the number of logical DOS drives in the system. The DOS CONFIG.SYS parameter LASTDRIVE controls this value. The logical drives begin with drive letter A: and continue consecutively through the alphabet up to the LASTDRIVE value. For example, if logicalDrivesP is 10, the system contains drive devices A: through J:.
[in]drivespecifies the new default drive. It is an integer corresponding to the drive number. Drive A: is 1, drive B: is 2, and so on.
Returns
SUCCESS if no errors occurred. Otherwise, it returns ERROR. The current default drive is unchanged if the function failed.
Remarks
Each returned logical drive is not necessarily valid. The logical drives represent only space allocated internally for drive devices. A given logical device cannot be readable because no physical device is associated with it. Or, in the case of a removable drive, no media is in the drive.
See also
mdlFile_getDrive mdlFile_isValidDrive
bool mdlFile_validDesignFile ( bool *  pThreeD,
DgnPlatform::DgnFileFormatType *  pFormat,
int *  pMajorVersion,
int *  pMinorVersion,
byte **  ppThumbnail,
int *  pThumbnailSize,
WCharCP  pFileName 
)

Tests whether the specified file is a valid MicroStation design file.

Parameters
[out]pThreeDindicates whether the file is a three-dimensional design file.
[out]pFormatan integer value indicating the format of the specified file is stored. Possible values are DgnFileFormatType::V7 for MicroStation/J format, DgnFileFormatType::V8 for the MicroStation V8 format, DgnFileFormatType::DWG for Autocad dwg format, and DgnFileFormatType::DXF for Autocad dxf format.
[out]pMajorVersionindicates the major version of the design file.
[out]pMinorVersionindicates the minor version of the design file.
[out]ppThumbnailset to point to the thumbnail image of the design file, used in the preview pane in the MicroStation Manager window. The image data is a BITMAPINFO structure.
[out]pThumbnailSizeindicates the size of the thumbnail image buffer.
[in]pFileNamethe fully qualified path to the design file.
Returns
true if the specified file is a valid design file, otherwise false.

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.