Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
48
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать
Using External Code in LabVIEW

Chapter 6 Function Descriptions

FCopy

MgErr FCopy(oldPath, newPath);

Purpose

Copies a file, preserving the type, creator, and access rights. The file to be copied must not be open. If an error occurs, the new file is not created.

Parameters

Name

Type

Description

 

 

 

 

 

 

oldPath

Path

Path of the file or directory you want to copy.

 

 

 

newPath

Path

Path, including filename, where you want to

 

 

store the new file.

 

 

 

Return Value

mgErr, which can contain the following errors:

mgArgErr

A bad argument was passed to the function. Verify the path.

fNotFound

File not found.

fNoPerm

Access was denied; the file, directory, or disk is locked or

 

protected.

fDiskFull

Disk is full.

fDupPath

The new file already exists.

fIsOpen

The original file is open for writing.

fTMFOpen

Too many files are open.

mFullErr

Insufficient memory.

fIOErr

Unspecified I/O error.

6-54

www.ni.com

Chapter 6 Function Descriptions

FCreate

MgErr FCreate(fdp, path, permissions, openMode, denyMode, group);

Purpose

Creates a file with the name and location specified by path and with the specified permissions, and opens it for writing and reading, as specified by openMode. If the file already exists, the function returns an error.

You can use denyMode to control concurrent access to the file from within LabVIEW. You can use the group parameter to assign the file to a UNIX group; in Windows or Macintosh, group is ignored.

If the function creates the file, the resulting file descriptor is stored in the address referred to by fdp. If an error occurs, the function stores 0 in the address referred to by fdp and returns an error.

Note Before you call this function, make sure that you understand how to use the fdp parameter. Refer to the Pointers as Parameters section in Chapter 3, CINs, for more information about using this parameter.

Parameters

Name

Type

Description

 

 

 

 

 

 

fdp

File *

Address at which FCreate stores the file

 

 

descriptor for the new file. If FCreate fails,

 

 

it stores 0 in the address fdp. Refer to the

 

 

Pointers as Parameters section in Chapter 3,

 

 

CINs, for more information about using this

 

 

parameter.

 

 

 

path

Path

Path of the file you want to create.

 

 

 

permissions

int32

Permissions to assign to the new file.

 

 

 

openMode

int32

Access mode to use in opening the file. The

 

 

following values are defined in the file

 

 

extcode.h:

 

 

openReadOnly—Open for reading.

 

 

openWriteOnly—Open for writing.

 

 

openReadWrite—Open for both

 

 

reading and writing.

 

 

 

© National Instruments Corporation

6-55

Using External Code in LabVIEW

File is already open for writing. This error is returned only in Macintosh and Solaris. Windows returns fIOErr when the file is already open for writing.
Access was denied, because the file is locked or protected. A file of that name already exists.
Too many files are open. Unspecified I/O error.
A bad argument was passed to the function. Verify the path.

Chapter 6 Function Descriptions

Name

Type

 

Description

 

 

 

 

 

 

denyMode

int32

Mode that determines what level of

 

 

concurrent access to the file is allowed.

 

 

The following values are defined in the file

 

 

extcode.h:

 

 

denyReadWrite—Prevents others

 

 

 

from reading from and writing to

 

 

 

the file while it is open.

 

 

denyWriteOnly—Prevents others

 

 

 

from writing to the file only while it

 

 

 

is open.

 

 

denyNeither—Allows others to

 

 

 

read from and write to the file while

 

 

 

it is open.

 

 

 

group

PStr

UNIX group you want to assign to the new

 

 

file.

 

 

 

 

Return Value

mgErr, which can contain the following errors: mgArgErr

fIsOpen

fNoPerm fDupPath fTMFOpen fIOErr

Using External Code in LabVIEW

6-56

www.ni.com

Chapter 6 Function Descriptions

FCreateAlways

MgErr FCreateAlways(fdp, path, permissions, openMode, denyMode, group);

Purpose

Creates a file with the name and location specified by path and with the specified permissions, and opens the file for writing and reading, as specified by openMode. If the file already exists, this function opens and truncates the file.

You can use denyMode to control concurrent access to the file from within LabVIEW. You can use the group parameter to assign the file to a UNIX group; in Windows or Macintosh, group is ignored.

If the function creates the file, the resulting file descriptor is stored in the address referred to by fdp. If an error occurs, the function stores 0 in the address referred to by fdp and returns an error.

Note Before you call this function, make sure that you understand how to use the fdp parameter. Refer to the Pointers as Parameters section in Chapter 3, CINs, for more information about using this parameter.

Parameters

Name

Type

Description

 

 

 

 

 

 

fdp

File *

Address at which FCreateAlways stores

 

 

the file descriptor for the new file. If

 

 

FCreateAlways fails, it stores 0 in the

 

 

address fdp. Refer to the Pointers as

 

 

Parameters section in Chapter 3, CINs, for

 

 

more information about using this parameter.

 

 

 

path

Path

Path of the file you want to create.

 

 

 

permissions

int32

Permissions to assign to the new file.

 

 

 

openMode

int32

Access mode to use in opening the file.

 

 

The following values are defined in the file

 

 

extcode.h:

 

 

openReadOnly—Open for reading.

 

 

openWriteOnly—Open for writing.

 

 

openReadWrite—Open for both

 

 

reading and writing.

 

 

 

© National Instruments Corporation

6-57

Using External Code in LabVIEW

File is already open for writing. This error is returned only in Macintosh and Solaris. Windows returns fIOErr when the file is already open for writing.
Access was denied, because the file is locked or protected. A file of that name already exists.
Too many files are open. Unspecified I/O error.
A bad argument was passed to the function. Verify the path.

Chapter 6 Function Descriptions

Name

Type

 

Description

 

 

 

 

 

 

denyMode

int32

Mode that determines what level of

 

 

concurrent access to the file is allowed.

 

 

The following values are defined in the file

 

 

extcode.h:

 

 

denyReadWrite—Prevents others

 

 

 

from reading from and writing to

 

 

 

the file while it is open.

 

 

denyWriteOnly—Prevents others

 

 

 

from writing to the file only while it

 

 

 

is open.

 

 

denyNeither—Allows others to

 

 

 

read from and write to the file while

 

 

 

it is open.

 

 

 

group

PStr

UNIX group you want to assign to the new

 

 

file.

 

 

 

 

Return Value

mgErr, which can contain the following errors: mgArgErr

fIsOpen

fNoPerm fDupPath fTMFOpen fIOErr

Using External Code in LabVIEW

6-58

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]