"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer0/File.cpp" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

File.cpp  (pymol-v1.8.6.0.tar.bz2):File.cpp  (pymol-v2.1.0.tar.bz2)
/* /*
* Copyright (c) Schrodinger, LLC. * Copyright (c) Schrodinger, LLC.
* *
* Basic file IO. * Basic file IO.
*/ */
#ifdef _WIN32
#include <vector>
#include <Windows.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "File.h" #include "File.h"
#include "MemoryDebug.h" #include "MemoryDebug.h"
/* /*
* Get the size from the current file pointer to the end of the file * Get the size from the current file pointer to the end of the file
*/ */
static long fgetsize(FILE *fp) { static long fgetsize(FILE *fp) {
skipping to change at line 47 skipping to change at line 52
return NULL; return NULL;
} }
if (size) if (size)
*size = filesize; *size = filesize;
contents[filesize] = '\0'; contents[filesize] = '\0';
return contents; return contents;
} }
#ifdef _WIN32
FILE * pymol_fopen(const char * filename, const char * mode) {
FILE *fp = fopen(filename, mode);
if (!fp) {
size_t len_filename = strlen(filename);
std::vector<wchar_t> wfilename(len_filename + 1);
std::vector<wchar_t> wmode(mode, mode + strlen(mode) + 1);
if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
filename, len_filename, wfilename.data(), wfilename.size()))
return NULL;
fp = _wfopen(wfilename.data(), wmode.data());
}
return fp;
}
#endif
/* /*
* Allocate memory and read the entire file for the given filename. * Allocate memory and read the entire file for the given filename.
* The file size is stored into the size pointer if not NULL. * The file size is stored into the size pointer if not NULL.
*/ */
char * FileGetContents(const char *filename, long *size) { char * FileGetContents(const char *filename, long *size) {
char *contents; char *contents;
FILE *fp = fopen(filename, "rb"); FILE *fp = pymol_fopen(filename, "rb");
if (!fp) if (!fp)
return NULL; return NULL;
contents = fgetcontents(fp, size); contents = fgetcontents(fp, size);
fclose(fp); fclose(fp);
return contents; return contents;
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)