Ignore:
Timestamp:
Feb 25, 2019, 1:57:11 PM (5 years ago)
Author:
knut
Message:

Added some recent changes from trunk (r889), including some new utility functions and exception handling and new (conditional) definition of type bool. Added some new logic concerning Python and Mono environment and search paths. Fixed problem with Mono updateStatus function. Changed response_print.h to #include locale.h unconditionally and xlocale.h conditionally; xlocale.h is non-standard and can probably be dropped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal.c

    r890 r896  
    917917}
    918918
     919/**
     920 * Check if file exists in specified folder
     921 *
     922 * @param dir the folder in which to search for file
     923 * @param name the name of the file (not full path)
     924 * @return a character string with the full path [dir/name], or NULL if the file does not exist
     925 *
     926 * @attention Caller is responsible for applying free() to the returned pointer
     927 */
     928char* file_exists(const char* dir, const char* name) {
     929        char* d = (dir != NULL ? dir : ".");
     930        if (name != NULL) {
     931                size_t length = strlen(d) + strlen(name) + 2; // including file separator and \0 character
     932                char* path = (char*)calloc(length, sizeof(char));
     933                snprintf(path, length, "%s/%s", d, name);
     934
     935                struct stat buffer;
     936                if (stat(path, &buffer) != 0) {
     937                        free(path);
     938                        path = NULL;
     939                }
     940                return path;
     941        }
     942        else {
     943                return NULL;
     944        }
     945}
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png