PhoenixPNG  0.1.0
Set of tools to ease use of png file
Loading...
Searching...
No Matches
check_png.cpp File Reference
#include <stdio.h>
#include "check_png.h"
+ Include dependency graph for check_png.cpp:

Go to the source code of this file.

Macros

#define PNG_BYTES_TO_CHECK   4
 

Functions

bool check_is_png (const PPath &fileName)
 Check if the given filename is a png file.
 

Macro Definition Documentation

◆ PNG_BYTES_TO_CHECK

#define PNG_BYTES_TO_CHECK   4

Definition at line 10 of file check_png.cpp.

Referenced by check_is_png().

Function Documentation

◆ check_is_png()

bool check_is_png ( const PPath & fileName)

Check if the given filename is a png file.

Parameters
fileName: name of the file to be checked
Returns
true if the given file is a png, false if not

Definition at line 16 of file check_png.cpp.

16 {
17 unsigned char buf[PNG_BYTES_TO_CHECK];
18
19 FILE * fp = fopen(fileName.c_str(), "rb");
20 /* Open the prospective PNG file. */
21 if(fp == NULL){return false;}
22
23 /* Read in some of the signature bytes. */
24 if(fread(buf, 1, PNG_BYTES_TO_CHECK, fp) != PNG_BYTES_TO_CHECK){
25 fclose(fp);
26 return false;
27 }
28 /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
29 * Return nonzero (true) if they match.
30 */
31 bool b(!png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK));
32 fclose(fp);
33 return b;
34}
#define PNG_BYTES_TO_CHECK
Definition check_png.cpp:10

References PNG_BYTES_TO_CHECK.

Referenced by PImagePng::read().

+ Here is the caller graph for this function: