libgphoto2 (libgphoto2): libgphoto2/gphoto2-file.c File Reference

- Main Page
- Data Structures
- Files
- Directories
- Related Pages

- File List
- Globals

# gphoto2-file.c File Reference

`#include "config.h"`
`#include <gphoto2/gphoto2-file.h>`
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <utime.h>`
`#include <gphoto2/gphoto2-port-log.h>`
`#include <gphoto2/gphoto2-port-portability.h>`
`#include <gphoto2/gphoto2-result.h>`

## Data Structures
struct | _CameraFile
## Defines
#define | CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
#define | CHECK_RESULT(result) {int r = (result); if (r < 0) return (r);}
#define | CHECK_MEM(m) {if (!(m)) return (GP_ERROR_NO_MEMORY);}
#define | MAX_PATH 256
## Functions
int | gp_file_new (CameraFile **file)
int | gp_file_free (CameraFile *file)
| descruct a CameraFile object.
int | gp_file_ref (CameraFile *file)
| Increase reference counter for CameraFile object.
int | gp_file_unref (CameraFile *file)
| Decrease reference counter for CameraFile object.
int | gp_file_append (CameraFile *file, const char *data, unsigned long int size)
int | gp_file_set_data_and_size (CameraFile *file, char *data, unsigned long int size)
int | gp_file_get_data_and_size (CameraFile *file, const char **data, unsigned long int *size)
int | gp_file_save (CameraFile *file, const char *filename)
int | gp_file_open (CameraFile *file, const char *filename)
int | gp_file_clean (CameraFile *file)
int | gp_file_copy (CameraFile *destination, CameraFile *source)
int | gp_file_get_name (CameraFile *file, const char **name)
int | gp_file_get_mime_type (CameraFile *file, const char **mime_type)
int | gp_file_set_name (CameraFile *file, const char *name)
int | gp_file_set_mime_type (CameraFile *file, const char *mime_type)
int | gp_file_detect_mime_type (CameraFile *file)
int | gp_file_adjust_name_for_mime_type (CameraFile *file)
int | gp_file_set_type (CameraFile *file, CameraFileType type)
int | gp_file_get_type (CameraFile *file, CameraFileType *type)
int | gp_file_set_color_table (CameraFile *file, const unsigned char *red_table, int red_size, const unsigned char *green_table, int green_size, const unsigned char *blue_table, int blue_size)
int | gp_file_set_width_and_height (CameraFile *file, int width, int height)
int | gp_file_set_header (CameraFile *file, const char *header)
int | gp_file_set_conversion_method (CameraFile *file, CameraFileConversionMethod method)
int | gp_file_convert (CameraFile *file, const char *mime_type)
int | gp_file_get_mtime (CameraFile *file, time_t *mtime)
int | gp_file_set_mtime (CameraFile *file, time_t mtime)

## Detailed Description

Author:
  Copyright 2000 Scott Fritzinger

Note:
  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

  This file contains internal functions. Use of these functions from external software modules is considered deprecated.

## Function Documentation

int gp_file_adjust_name_for_mime_type | ( | CameraFile * | file | ) |

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_append | ( | CameraFile * | file,
|  | const char * | data,
|  | unsigned long int | size |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | data |
  | size |

Returns:
  a gphoto2 error code.

int gp_file_clean | ( | CameraFile * | file | ) |

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_convert | ( | CameraFile * | file,
|  | const char * | mime_type |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | mime_type | a MIME type string

Returns:
  a gphoto2 error code.

int gp_file_copy | ( | CameraFile * | destination,
|  | CameraFile * | source |
| ) |  |  |

Parameters:

  | destination | a CameraFile
  | source | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_detect_mime_type | ( | CameraFile * | file | ) |

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_free | ( | CameraFile * | file | ) |

descruct a CameraFile object.

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_get_data_and_size | ( | CameraFile * | file,
|  | const char ** | data,
|  | unsigned long int * | size |
| ) |  |  |

Get a pointer to the data and the file's size.

Parameters:

  | file | a CameraFile
  | data |
  | size |

Returns:
  a gphoto2 error code.

Both data and size can be NULL and will then be ignored.

int gp_file_get_mime_type | ( | CameraFile * | file,
|  | const char ** | mime_type |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | mime_type | a pointer to a MIME type string

Returns:
  a gphoto2 error code.

int gp_file_get_mtime | ( | CameraFile * | file,
|  | time_t * | mtime |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | mtime |

Returns:
  a gphoto2 error code.

int gp_file_get_name | ( | CameraFile * | file,
|  | const char ** | name |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | name | a pointer to a name string

Returns:
  a gphoto2 error code.

int gp_file_get_type | ( | CameraFile * | file,
|  | CameraFileType * | type |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | type | a CameraFileType

Returns:
  a gphoto2 error code.

int gp_file_new | ( | CameraFile ** | file | ) |

Create new CameraFile object.

Parameters:

  | file | a pointer to a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_open | ( | CameraFile * | file,
|  | const char * | filename |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | filename |

Returns:
  a gphoto2 error code.

int gp_file_ref | ( | CameraFile * | file | ) |

Increase reference counter for CameraFile object.

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.

int gp_file_save | ( | CameraFile * | file,
|  | const char * | filename |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | filename |

Returns:
  a gphoto2 error code.

int gp_file_set_color_table | ( | CameraFile * | file,
|  | const unsigned char * | red_table,
|  | int | red_size,
|  | const unsigned char * | green_table,
|  | int | green_size,
|  | const unsigned char * | blue_table,
|  | int | blue_size |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | red_table |
  | red_size |
  | red_table |
  | green_size |
  | red_table |
  | blue_size |

Returns:
  a gphoto2 error code.

int gp_file_set_conversion_method | ( | CameraFile * | file,
|  | CameraFileConversionMethod | method |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | method | a CameraFileConversionMethod

Returns:
  a gphoto2 error code.

int gp_file_set_data_and_size | ( | CameraFile * | file,
|  | char * | data,
|  | unsigned long int | size |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | data |
  | size |

Returns:
  a gphoto2 error code.

int gp_file_set_header | ( | CameraFile * | file,
|  | const char * | header |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | header |

Returns:
  a gphoto2 error code.

int gp_file_set_mime_type | ( | CameraFile * | file,
|  | const char * | mime_type |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | mime_type | a MIME type string

Returns:
  a gphoto2 error code.

int gp_file_set_mtime | ( | CameraFile * | file,
|  | time_t | mtime |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | mtime |

Returns:
  a gphoto2 error code.

int gp_file_set_name | ( | CameraFile * | file,
|  | const char * | name |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | name | a pointer to a MIME type string

Returns:
  a gphoto2 error code.

int gp_file_set_type | ( | CameraFile * | file,
|  | CameraFileType | type |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | type | a CameraFileType

Returns:
  a gphoto2 error code.

int gp_file_set_width_and_height | ( | CameraFile * | file,
|  | int | width,
|  | int | height |
| ) |  |  |

Parameters:

  | file | a CameraFile
  | width |
  | height |

Returns:
  a gphoto2 error code.

int gp_file_unref | ( | CameraFile * | file | ) |

Decrease reference counter for CameraFile object.

Parameters:

  | file | a CameraFile

Returns:
  a gphoto2 error code.