User`s guide
7 Working with Target PC Files and File Systems
7-14
Getting a List of Open Files on the Target PC
You can get a list of open files on the target PC file system from the host PC by
using xPC Target methods on the host PC for the
xpctarget.fs object. Do this
to ensure you do not have files open unnecessarily. The target PC file system
limits the number of open files you can have to eight.
Use the method syntax to run an
xpctarget.fs object method. The syntax
method_name(fs_object, argument_list) can be replaced with
fs_object.method_name(argument_list)
For example, to get a list of open files for the file system object fsys,
1 If you have not already done so, in the MATLAB window, type the following
to assign the
xpctarget.fs object to a variable.
fsys=xpctarget.fs;
2 Type
fsys.filetable
If the file system has open files, a list like the following is displayed:
ans =
Index Handle Flags FilePos Name
------------------------------------------
0 00060000 R__ 8512 C:\DATA.DAT
1 00080001 R__ 0 C:\DATA1.DAT
2 000A0002 R__ 8512 C:\DATA2.DAT
3 000C0003 R__ 8512 C:\DATA3.DAT
4 001E0001 R__ 0 C:\DATA4.DAT
3 The table returns the open file handles in hexadecimal. To convert a handle
to one that other
xpctarget.fs methods, such as fclose, can use, use the
hex2dec function. For example,
h1 = hex2dec('001E0001'))
h1 =
1966081
4 To close that file, use the xpctarget.fs fclose method. For example,
fsys.fclose(h1);