SR Research Support Site
Macros | Functions
Data file utilities

Macros

#define BAD_FILENAME   -2222
 
#define BAD_ARGUMENT   -2223
 
#define REPLACE_FILE   0x4000
 
#define EDFNAME_MAXLENGTH   82
 
#define receive_data_file   receive_data_file_dialog
 

Functions

INT16 eyelink_request_file_read (const char FARTYPE *src)
 
INT16 eyelink_get_file_block (void FARTYPE *buf, INT32 FARTYPE *offset)
 
INT16 eyelink_request_file_block (UINT32 offset)
 
INT16 eyelink_end_file_transfer (void)
 
INT32 receive_data_file (const char *src, const char *dest, INT16 options)
 
INT32 receive_data_file_feedback (const char *src, const char *dest, INT16 dest_is_path, short(*progress)(unsigned int size, unsigned int received))
 
INT32 receive_data_file_feedback64 (const char *src, const char *dest, INT16 options, short(*progress)(char *fileName, UINT64 size, UINT64 received))
 
INT32 send_data_file_feedback (char *src, char *dest, INT16 options, void(*progress)(unsigned int size, unsigned int received))
 
INT32 send_data_file_mem (char *src, char *fname, int file_size, void(*progress)(unsigned int size, unsigned int received))
 
INT32 send_data_file (char *src, char *dest, INT16 dest_is_path)
 
INT16 open_data_file (char *name)
 
INT16 close_data_file (void)
 
INT16 eyelink_set_options (const char *options)
 
void splice_fname (const char *fname, const char *path, char *ffname)
 
int check_filename_characters (const char *name)
 
int file_exists (const char *path)
 
int create_path (const char *path, INT16 create, INT16 is_dir)
 
INT32 receive_data_file_dialog (char *src, char *dest, INT16 dest_is_path)
 

Detailed Description

Macro Definition Documentation

#define BAD_ARGUMENT   -2223

Invalid argument

#define BAD_FILENAME   -2222

Bad file name

#define EDFNAME_MAXLENGTH   82

Maximum length (in bytes) of an EDF name, including the base name and the .edf file-type suffix. This does not include the terminating null byte.

#define receive_data_file   receive_data_file_dialog

This macro is introduced so that the old eyelink projects compiled against new libraries, the file transfer behaves the same as the old receive_data_file in win32 platform See receive_data_file_dialog()

#define REPLACE_FILE   0x4000

Replace existing data file(s)

Function Documentation

int check_filename_characters ( const char *  name)

Checks file name for legality. Attempts to ensure cross-platform for viewer. No spaces allowed as this interferes with messages. Assume viewer will translate forward/backward slash. Windows: don't allow <>:"/| Also, device names, such as aux, con, lpt1, and prn are not allowed in windows. forward slashes is missed.

INT16 close_data_file ( void  )

Closes any open EDF file.

Returns
Returns 0 if success, else error code.
int create_path ( const char *  path,
INT16  create,
INT16  is_dir 
)

Checks if path exists. Will create directory if 'create'. Creates directory from last name in 'path', unless ends with '\' or 'is_dir' nonzero. Otherwise, last item is assumed to be filename and is dropped.

Returns
0 if exists, 1 if created, -1 if failed.
INT16 eyelink_end_file_transfer ( void  )

Aborts send of file.

Returns
0 if OK, else send error.
Remarks
Internal function. use receive_data_file()
INT16 eyelink_get_file_block ( void FARTYPE *  buf,
INT32 FARTYPE *  offset 
)

Get next block of file. If <offset> is not NULL, will be filled with block-start offset in file.

Returns
negative if error, NO_REPLY if waiting for packet, else block size (0..512). size is < 512 (can be 0) if at EOF.
Remarks
Internal function. use receive_data_file()
INT16 eyelink_request_file_block ( UINT32  offset)

Ask for next block of file, reads from <offset>.

Remarks
Internal function. use receive_data_file()
INT16 eyelink_request_file_read ( const char FARTYPE *  src)

Request send of file "src". If "", gets last data file.

Returns
0 if OK, else send error.
Remarks
Internal function. use receive_data_file()
INT16 eyelink_set_options ( const char *  options)

Set options.

Parameters
optionsText specifying options. Currently long edf file name support is supported. Eg. eyelink_set_options("longname=1"). Calling this before open edf file will enable long file name eceeding 8 char limitation. The maximum length of a long EDF name is defined by EDFNAME_MAXLENGTH.
Returns
Returns 1 if success, else error code -1 for parsing errors and 0 for no options.
int file_exists ( const char *  path)

Checks if file and/or path exists.

Returns
0 if does not exist, 1 if exists, -1 if cannot overwrite.
INT16 open_data_file ( char *  name)

Opens an EDF file, closes any existing file.

Parameters
nameName of data file,which can only use letters(uppercase and lowercase), numbers(0-9),and underscore(appears from 2nd place). The base file name (no path or file type extension/suffix) should not exceed 8 characters; the name extension can only be .edf. When long EDF names are enabled, using eyelink_set_options("longname=1"), then the maximum length of the EDF base name becomes 78 characters.
Returns
Returns 0 if success, else error code.
See also
eyelink_set_options( ) , EDFNAME_MAXLENGTH
INT32 receive_data_file ( const char *  src,
const char *  dest,
INT16  options 
)

This receives a data file from the EyeLink tracker PC.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). This must be a valid file name or directory name.
[in]options0 files placed at the same folder where it executes 1 appends file name to <dest> as a directory path. 2 download vFile in addition to edf 3 download vFile & edf and append file name to <dest> as a directory path. 4 download only vFile and place it in the same folder 5 download only vFile and append file name to <dest> as a directory path. 6 download edf file and vFile
Returns
0 if file transfer was cancelled due to edf file missing at tracker.
Size of file in bytes, if successful.
-1 if file size is negative.
-2 if cannot create local file.
-3 if file transfer was cancelled.
-4 if file transfer was aborted.
-5 if error occurred while writing file.
-6 if link was terminated.
Example: See open_data_file()
See also
close_data_file() and open_data_file()
Remarks
If linked against eyelink_exptkit20.lib or w32_dialogs.h is included, the behaviour of this function is receive_data_file_dialog().
The return value cannot exceed 2^32-1 (see INT_MAX in limits.h). Data files that are larger than 2^32-1 bytes can still be transferred successfully, although the return value will be capped. If the return value is 2^32-1 then it is necessary to manually check the size of the transferred data file.
INT32 receive_data_file_dialog ( char *  src,
char *  dest,
INT16  dest_is_path 
)

This receives a data file from the EyeLink tracker PC with graphical progressbar. This function only available in Win32 platform.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). If "" (empty string), prompts for file name.
[in]dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
Returns
0 if file transfer was cancelled.
Size of file if successful.
FILE_CANT_OPEN if no such file.
FILE_XFER_ABORTED if data error.
\sa \c receive_data_file()
INT32 receive_data_file_feedback ( const char *  src,
const char *  dest,
INT16  dest_is_path,
short(*)(unsigned int size, unsigned int received)  progress 
)

This receives a data file from the EyeLink tracker PC. Exact same as receive_data_file(). except the feedback parameters can be used for showing what is the full size of the edf file and how much is received so far. This function is currently used internally only.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). This must be a valid file name or directory name.
[in]dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
[in]progressA function pointer, that takes fileName as string, size and received size integers. This allows, one to display progress bar on edf file transfer.
Returns
0 if file transfer was cancelled due to edf file missing at tracker.
Size of file if successful.
-1 if file size is negative.
-2 if cannot create local file. -3 if file transfer was cancelled -4 if file transfer was aborted -5 if error occurred while writing file -6 if link was terminated
\sa \c receive_data_file, \c close_data_file() and \c open_data_file()
INT32 receive_data_file_feedback64 ( const char *  src,
const char *  dest,
INT16  options,
short(*)(char *fileName, UINT64 size, UINT64 received)  progress 
)

This receives a data file from the EyeLink tracker.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). This must be a valid file name or directory name.
[in]options0 files placed at the same folder where it executes. E.g. receive_data_file_feedback64( "Host.edf" , "Local.edf", 0, NULL); 1 appends file name to <dest> as a directory path. E.g. receive_data_file_feedback64( "Host.edf" , "LocalFolder", 1, NULL); 2 download vFile in the folder with the edf file name without the extension in addition to edf 3 download vFile & edf and append file name to <dest> as a directory path. 4 download only vFile and place it in the folder 5 download only vFile and append file name to <dest> as a directory path. 6 download vFile to the folder in the edf file name.directory. E.g. receive_data_file_feedback64( "Host.edf", "LocalFolder/Local.edf", 6, NULL);
[in]progress- function pointer ((char * fileName, UINT64 size,UINT64 received)) to get progress update
Returns
0 if file transfer was cancelled due to edf file missing at tracker.
Size of file if successful.
-1 if file size is negative.
-2 if cannot create local file.
-3 if file transfer was cancelled.
-4 if file transfer was aborted.
-5 if error occurred while writing file.
-6 if link was terminated.
Example: See open_data_file()
See also
close_data_file() and open_data_file()
Remarks
The default behaviour is to check whether the destination name or path is in use. Naming conflicts are resolved by appending the date and time in a suffix with the form _DATE_TIME, or more specifically _YYYYMMDD_HHMMSS; the .edf file-type suffix will always follow the resolving date/time suffix. If a file called local/Host.edf already exists then Host.edf will be copied as e.g. local/Host_20250630_141530.edf, without altering the original local/Host.edf.

If vFiles are also requested then name conflict resolution is achieved by creating a new sub-directory in the destination directory of the EDF, then the EDF and vFiles are placed inside of it. The new directory uses the source name (without .edf suffix) plus the date/time suffix. Should local/Host.edf or local/Host/*.evf already exist when transferring Host.edf and its vFile(s) to local/, then a new directory called e.g. local/Host_20250630_141530/ will be created. New copies of Host.edf and the vFiles will be transferred to local/Host_20250630_141530/.

It may be desirable to discard exsiting files instead of renaming the new copies. Naming resolution can be disabled using the bitwise-OR operator to add the REPLACE_FILE flag to the desired value of the options parameter. For instance, REPLACE_FILE | 2 will download the source EDF and its vFile to the current working directory. If any EDF or vFile with the same name already exists then they will first be removed; this removal will be non- recoverable.

The progress function must return a short integer. If a value of 10 is
returned while a video file (vFile) is in the process of being transferred
then that transfer will be aborted and receive_data_file_feedback64 will
return -3. The progress function can safely return a value of 0 without
causing a vFile transfer to abort.

If linked against eyelink_exptkit20.lib or w32_dialogs.h is included,
the behaviour of this function is receive_data_file_dialog().
INT32 send_data_file ( char *  src,
char *  dest,
INT16  dest_is_path 
)

This function is equivalent to calling send_data_file_feedback() with NULL for the progress parameter. In other words, a file can be sent to the EyeLink tracker without reporting progress. Otherwise, the first three parameters take the same input as send_data_file_feedback(), and the same return values are produced.

INT32 send_data_file_feedback ( char *  src,
char *  dest,
INT16  options,
void(*)(unsigned int size, unsigned int received)  progress 
)

This function sends a file to the EyeLink tracker. Source destination file name should be given. Using this function, an image or video can be uploaded from the display PC to the host Tracker PC. The image can later be used as a Gaze Cursor Backdrop via a call to eyecmd_printf( "draw_image %s" , dest ), where dest is the same string that was provided to send_data_file_feedback( ).

Files may be transferred once a link to the Tracker software has been established. A transferred file will then be available until the Tracker software has been closed. Then, all transferred files will be automatically removed from the Tracker PC.

This function can transfer one file at a time. A maximum of 100 files may be transferred to the Tracker PC in a given session. Any additional files that are transferred in the same session will replace older ones.

The maximum size of any one image or video file can be 3145728 bytes, while the total sum of all transferred files may not exceed 300 MB.

Parameters
srcName of local file, including any file-type suffix (max length 1024 incl. null byte).
destString that the host will use to uniquely identify the image/video data (max length 20 printable chars.).
optionsReserved for future use. Set to 0 (zero).
progressA function pointer, that takes size and received size integers. This allows, one to display progress bar on file transfer.
Returns
Returns size of file if transferred file size is equal to the real file size.
-1 if fail to connect tracker ftpd.
-2 if fail to open file.
-3 src or dest is invalid i.e. NULL, empty string, or too long.
-4 if fail to receive reply from tracker ftpd.
-5 if transferred file size is unequal to the real file size.
INT32 send_data_file_mem ( char *  src,
char *  fname,
int  file_size,
void(*)(unsigned int size, unsigned int received)  progress 
)

This function is equivalent to send_data_file_feedback(), except that the source of the file is a memory buffer rather than a regular file.

Parameters
srcPoints to a buffer containing the file that will be transferred to the EyeLink.
fnameName of eye tracker file to write to (including extension).
file_sizeSize of the file to be transferred, in bytes.
progressA function pointer, that takes size and received size integers. This allows, one to display progress bar on file transfer.
Returns
Returns size of file if transferred file size is equal to the real file size.
-1 if fail to connect tracker ftpd.
-2 if fail to open file on tracker.
-3 if fail to initiate file transfer.
-4 if fail during transfer via tracker ftpd.
-5 if transferred file size is unequal to the real file size.
void splice_fname ( const char *  fname,
const char *  path,
char *  ffname 
)

Splice 'path' to 'fname', store in 'ffname'. Tries to create valid concatenation. If 'fname' starts with '\', just adds drive from 'path'. If 'fname' contains drive specifier, it is not changed.


Copyright ©2002-2026, SR Research Ltd.