---
name: "NJB_Get_File"
section: "3"
platform: "linux"
package: "libnjb1-doc"
version: "1.1-2"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/NJB_Get_File"
---

# NJB\_Get\_File(3)

upload a copy of a file from the NJB to the host

## NAME

NJB\_Get\_File - upload a copy of a file from the NJB to the host

## LIBRARY

libnjb

## SYNOPSIS

\#include \<sys/types.h\> #include \<libnjb.h\>

extern int njb\_error

int NJB\_Get\_File (njb\_t  **\*njb**, u\_int32\_t **fileid**, u\_int32\_t **size**, const char **\*path**, XferCallback **\*callback**, void **\*data)**

## DESCRIPTION

This function uploads a datafile from the NJB (without deleting it from the NJB) and saves it to the filename specified by **\*path**. Data files are not music tracks, but general data storage containers on the jukebox.

The desired datafile's file ID is stored in **fileid**. Note that the calling program must also know the size of the file to be transferred, and sent in the **size** parameter.  Both the datafile ID and the file size can be found in the datafile tag for the desired datafile, as returned by NJB\_Get\_Datafile\_Tag (3). Generally, the calling program should fetch (and cache) the complete datafile list from the NJB, so that all of this information is readily available.

For reliability, the datafile is first downloaded to a temporary directory (see [**NJB\_Get\_TmpDir**(3)](/NJB_Get_TmpDir/3.md)) before being copied into place.  By default, the temporary directory is /tmp, but it can be changed by the [**NJB\_Set\_TmpDir**(3)](/NJB_Set_TmpDir/3.md) function.

The  **callback** parameter is a pointed to a callback function, as described in [**NJB\_Get\_File**(3)](/NJB_Get_File/3.md).

The  **data** parameter is a pointer to user data of any kind that the user of the library wants to associate with this transfer. This pointer is used for example when accessing several different jukeboxes from withing one program. The XferCallback will also be delivering this pointer to the target routine for dereferencing. If this parameter is not used (in for example single-device, single-threaded programs) it may be set to **NULL.**

## RETURN VALUES

If the transfer is successful, 0 is returned.  Otherwise, -1 is returned and **njb\_error** is set as follows:

- EO\_ABORTED

  The transfer was aborted by the user (the callback function returned -1).

- EO\_BADSTATUS

  A non-zero status was returned by the NJB during the file transfer.

- EO\_CANTMOVE

  The transferred datafile could not be moved from the temporary directory to the specified location (see the **\*path** parameter).

- EO\_NOMEM

  There was not enough memory to allocate the file transfer buffer.

- EO\_NULLTMP

  The temporary directory is undefined (a NULL pointer).

- EO\_RDSHORT

  The NJB sent fewer bytes than expected on the bulk data pipe.

- EO\_TMPFILE

  The temporary transfer file could not be created in the temporary directory.

- EO\_USBBLK

  An I/O error occurred on the bulk data pipe.

- EO\_USBCTL

  An I/O error occurred on the control pipe.

- EO\_WRFILE

  An error occurred while writing to the temporary transfer file.

- EO\_XFERDENIED

  The NJB returned a non-zero status when the file transfer was requested. The datafile may be write protected, or the given track ID may not exist.

- EO\_XFERERROR

  The NJB returned a non-zero status when the host requested verification of the file transfer.

## SEE ALSO

[NJB\_Get\_TmpDir(3)](/NJB_Get_TmpDir/3.md), [NJB\_Get\_Datafile\_Tag(3)](/NJB_Get_Datafile_Tag/3.md), [NJB\_Set\_TmpDir(3)](/NJB_Set_TmpDir/3.md),  [XferCallback(3)](/XferCallback/3.md)
