APIEnv_​CopyFilesIntoLibraryID

Copies files into a folder inside a loaded library.

    GSErrCode ACAPI_Environment (
        APIEnv_CopyFilesIntoLibraryID,
        const IO::Location*             targetFolderLocationInLibrary,
        const GS::Array<IO::Location>*  filesToCopy,
        const bool*                     overwriteIfExists
    );

 

Parameters

targetFolderLocationInLibrary
[in] The target folder location.
filesToCopy
[in] The list of files to be copied.
overwriteIfExists
[in] Overwrite existing files found on the target location (optional parameter; if omitted, the value is considered false, resulting existing files to be skipped).

 

Return Values

APIERR_BADPARS
The target folder location parameter is invalid or nullptr.
APIERR_NOPLAN
There is no user project.
APIERR_NOTMINE
The target folder is not reserved by the current user in Teamwork.
APIERR_READONLY
The target location is not writable.
APIERR_NOACCESSRIGHT
The user does not have access right to the BIM server library, or the BIM server is not available.
APIERR_REFUSEDPAR
The given target location is not a subfolder of any of the active linked or server libraries, nor the Embedded Library.
NoError
The function has completed with success.

For other common API errors see the API Errors document.

 

Remarks

The function copies file from the passed locations into a folder in an existing library loaded in the current project. The target folder must be writable and, in Teamwork, must be reserved.

 

Example


GS::Array<IO::Location> filesToCopy;
API_SpecFolderID specID = API_UserDocumentsFolderID;
IO::Location fileLocation;
ACAPI_Environment (APIEnv_GetSpecFolderID, &specID, &fileLocation);
filesToCopy.Push (IO::Location (fileLocation, IO::Name ("Test1.JPG")));
filesToCopy.Push (IO::Location (fileLocation, IO::Name ("Test2.JPG")));

GS::Array<API_LibraryInfo> libInfo;
GSErrCode err = ACAPI_Environment (APIEnv_GetLibrariesID, &libInfo);
if (err == NoError) {
    for (UInt32 ii = libInfo.GetSize (); ii > 0; --ii) {
        const API_LibraryInfo& libraryInfo = libInfo[ii - 1];
        if (libraryInfo.libraryType == API_LocalLibrary || libraryInfo.libraryType == API_EmbeddedLibrary || libraryInfo.libraryType == API_ServerLibrary) {
            IO::Location targetFolderLocation = libraryInfo.location;
            bool overwriteIfExists = true;
            err = ACAPI_Environment (APIEnv_CopyFilesIntoLibraryID, &targetFolderLocation, &filesToCopy, &overwriteIfExists);
            break;
        }
    }
}

 

Requirements

Version: API 20 or later
Header: APIdefs_Environment.h

 

See Also

APIEnv_CreateFolderInLibraryID, APIEnv_GetLibrariesID, APIEnv_AddLibrariesID,
ACAPI_Environment, API Functions