- Linux: Implement resource loading in cefclient.

- Fix incorrect svn:eol-style properties.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@375 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-11-12 04:47:00 +00:00
parent 1dab15313a
commit f211cbbc2e
11 changed files with 442 additions and 310 deletions

View File

@@ -11,20 +11,48 @@
bool GetResourceDir(std::string& dir) {
char buff[1024];
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
if (len != -1) {
buff[len] = '\0';
dir = std::string(buff);
return true;
} else {
/* handle error condition */
// Retrieve the executable path.
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
if (len == -1)
return false;
}
buff[len] = 0;
// Remove the executable name from the path.
char* pos = strrchr(buff, '/');
if (!pos)
return false;
// Add "files" to the path.
strcpy(pos+1, "files");
dir = std::string(buff);
return true;
}
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
return false;
std::string path;
if (!GetResourceDir(path))
return false;
path.append("/");
path.append(resource_name);
FILE* f = fopen(path.c_str(), "rb");
if (!f)
return false;
size_t bytes_read;
char buff[1024*8];
do {
bytes_read = fread(buff, 1, sizeof(buff)-1, f);
if (bytes_read > 0)
resource_data.append(buff, bytes_read);
} while(bytes_read > 0);
fclose(f);
return true;
}
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {