Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Labview Code Interface Reference Manual.pdf
Скачиваний:
33
Добавлен:
29.05.2015
Размер:
1.13 Mб
Скачать

Chapter 7 File Manager Functions

typedef struct {

 

int32

size;

/* size in bytes of a kuhvkjhgvku

 

 

volume */

int32

used;

/* number of bytes used on volume

 

 

*/

int32

free;

/* number of bytes available for

 

 

use on volume */

}

VInfoRec;

 

File Manager Functions

Performing Basic File Operations

FCreate

syntax

MgErr

FCreate(fdp, path, permissions, openMode,

 

 

denyMode, group);

FCreate 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, an error is returned.

You can use denyMode to control concurrent access to the file from within LabVIEW. The group parameter allows you to assign the file to a UNIX group; under 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 attempting to call this function, make sure that you understand

 

how to use the fdp parameter. See the Pointers as Parameters section of

 

Chapter 1, CIN Overview, for more information about this parameter.

Parameter

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.

 

 

See the Pointers as Parameters section of

 

 

Chapter 1, CIN Overview, for more information

 

 

about using this parameter.

path

Path

Path of the file that you want to create.

LabVIEW Code Interface Reference Manual

7-4

National Instruments Corporation

 

 

 

Chapter 7 File Manager Functions

 

permissions

int32

Permissions to assign to the new file. See the File

 

 

 

Manager Data Structures section for a description

 

 

 

of permissions.

 

openMode

int32

Access mode to use in opening the file. Can have the

 

 

 

following values, which are defined in the file

 

 

 

extcode.h.

 

 

 

openReadOnly: Open for reading.

 

 

 

openWriteOnly: Open for writing

 

 

 

openReadWrite: Open for both reading

 

 

 

and writing

 

denyMode

int32

Mode that determines what level of concurrent

 

 

 

access to the file is allowed. Can have the following

 

 

 

values, which 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.

returns

MgErr, which can contain the errors in the following list.

 

Error

Description

 

 

 

mgArgErr

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

 

fIsOpen

File is already open for writing. This error is returned only on the

 

 

Macintosh and the Sun. The PC returns fIOErr when the file is

 

 

already open for writing.

 

fNoPerm

Access denied (something is locked/protected).

 

fDupPath

A file of that name already exists.

 

fTMFOpen

Too many files open.

 

fIOErr

Unspecified I/O error occurred.

 

 

 

 

 

FCreateAlways

syntax

MgErr

FCreateAlways(fdp, path, permissions,

 

 

openMode, denyMode, group);

National Instruments Corporation

7-5

LabVIEW Code Interface Reference Manual

Chapter 7 File Manager Functions

FCreateAlways 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. The group parameter allows you to assign the file to a UNIX group; under 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 attempting to call this function, make sure that you understand how to use the fdp parameter. See the Pointers as Parameters section of Chapter 1, CIN Overview, for more information about this parameter.

Parameter

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.

 

 

See the Pointers as Parameters section of

 

 

Chapter 1, CIN Overview, for more information

 

 

about using this parameter.

path

Path

Path of the file that you want to create.

permissions

int32

Permissions to assign to the new file. See the File

 

 

Manager Data Structures section of this chapter for

 

 

a description of permissions.

openMode

int32

See FMOpen for a description of openMode.

denyMode

int32

See FMOpen for a description of denyMode.

group

PStr

UNIX group you want to assign to the new file.

returns

MgErr, which can contain the errors in the following list.

Error

Description

 

mgArgErr

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

fIsOpen

File is already open for writing. This error is returned only on the

 

Macintosh and the Sun. The PC returns fIOErr when the file is

 

already open for writing.

fNoPerm

Access denied (something is locked/protected).

fDupPath

A file of that name exists.

fTMFOpen

Too many files open.

fIOErr

Unspecified I/O error occurred.

LabVIEW Code Interface Reference Manual

7-6

National Instruments Corporation

Chapter 7 File Manager Functions

FMClose

syntax

MgErr

FMClose(fd);

FMClose closes the file associated with the file descriptor fd.

Parameter

Type

Description

fd

File

File descriptor associated with the file you want to

 

 

close.

returns

MgErr, which can contain the errors in the following list.

 

Error

Description

 

mgArgErr

Not a valid file descriptor.

 

fIOErr

Unspecified I/O error occurred.

 

 

 

FMOpen

syntax

MgErr

FMOpen(fdp, path, openMode, denyMode);

Note:

Before attempting to call this function, make sure that you understand

 

how to use the fdp parameter. See the Pointers as Parameters section of

 

Chapter 1, CIN Overview, for more information about this parameter.

FMOpen opens a file with the name and location specified by path for writing and reading, as specified by openMode.

With the denyMode parameter, you control concurrent access to the file from within LabVIEW.

If this function opens the file, the resulting file descriptor is stored in the address referred to by fdp. If an error occurs, 0 is stored in the address referred to by fdp and the error is returned.

Parameter

Type

Description

fdp

File *

Address at which FMOpen stores the file descriptor

 

 

for the opened file. If the function fails, FMOpen

 

 

stores 0 in the address fdp.

National Instruments Corporation

7-7

LabVIEW Code Interface Reference Manual

Chapter 7 File Manager Functions

 

 

See the Pointers as Parameters section of

 

 

Chapter 1, CIN Overview, for more information

 

 

about using this parameter.

path

Path

Path of the file that you want to open.

openMode

int32

Access mode to use in opening the file. Can have the

 

 

following values, which are defined in the file

 

 

extcode.h.

 

 

openReadOnly: Open for reading.

 

 

openWriteOnly: Open for writing; file is

 

 

not truncated (data is not removed). On the

 

 

Macintosh, this mode provides true write-

 

 

only access to files. On a PC or a UNIX

 

 

system, LabVIEW I/O functions are built in

 

 

the C standard I/O library, with which you

 

 

have write-only access to a file only if you are

 

 

truncating the file or making the access

 

 

append-only. Therefore, this mode actually

 

 

allows both read and write access to files on

 

 

a PC or UNIX system.

 

 

openReadWrite: Open for both reading

 

 

and writing.

 

 

openWriteOnlyTruncate: Open for

 

 

writing; truncates the file.

denyMode

int32

Mode that determines what level of concurrent

 

 

access to the file is allowed. Can have the following

 

 

values, which 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.

returns

MgErr, which can contain the errors in the following list.

Error

Description

 

mgArgErr

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

LabVIEW Code Interface Reference Manual

7-8

National Instruments Corporation

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