1 // Copyright (c) 2013 The Chromium Embedded Framework Authors. 2 // Portions copyright (c) 2011 The Chromium Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 #include "tests/shared/browser/resource_util.h" 7 8 #include <stdio.h> 9 #include <string.h> 10 #include <unistd.h> 11 12 namespace client { 13 GetResourceDir(std::string & dir)14bool GetResourceDir(std::string& dir) { 15 char buff[1024]; 16 17 // Retrieve the executable path. 18 ssize_t len = readlink("/proc/self/exe", buff, sizeof(buff) - 1); 19 if (len == -1) 20 return false; 21 22 buff[len] = 0; 23 24 // Remove the executable name from the path. 25 char* pos = strrchr(buff, '/'); 26 if (!pos) 27 return false; 28 29 // Add "cefclient_files" to the path. 30 strcpy(pos + 1, "cefclient_files"); 31 dir = std::string(buff); 32 return true; 33 } 34 35 } // namespace client 36