Enlightenment CVS committal

Author  : doursse
Project : e17
Module  : proto/evil

Dir     : e17/proto/evil/src/lib


Modified Files:
        Evil.h evil.c 


Log Message:
* src/lib/Evil.h:
* src/lib/evil.c: (evil_getcwd):
add getgwd-like function
* src/lib/dlfcn/dlfcn.c: (dladdr):
* src/lib/dlfcn/dlfcn.h:
add dladdr-like function. Formatting
Remove unused define
* src/lib/mman/sys/mman.h:
remove unused define

===================================================================
RCS file: /cvs/e/e17/proto/evil/src/lib/Evil.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- Evil.h      26 Apr 2008 16:27:46 -0000      1.9
+++ Evil.h      28 Apr 2008 14:34:54 -0000      1.10
@@ -389,8 +389,39 @@
  *
  * @ingroup Evil
  */
+
 EAPI const char *evil_tmpdir_get(void);
 
+/**
+ * @brief Get the current directory.
+ *
+ * @param buffer Buffer to store the current directory.
+ * @param size Size of the buffer.
+ * @return The current directory.
+ *
+ * On Windows desktop, use the _getcwd function in MSVCRT.
+ *
+ * On Windows CE, get the current directory by extracting the path
+ * from the executable that is running and put the result in @p buffer
+ * of length @p size. If @p size is less or equal than 0, return NULL.
+ * If the current absolute path would require a buffer longer than
+ * @p size elements, NULL is returned. If @p buffer is NULL, a buffer
+ * of length @p size is allocated and is returned. If the allocation
+ * fails, NULL is returned. On success, @p buffer is returned and
+ * contains the current directory. The last '\' is not included.
+ * If @p buffer is NULL, the returned value must be freed if not NULL.
+ *
+ * Specially usefull on WinCE where the current directory functionality
+ * is not supported.
+ *
+ * Conformity: Almost POSIX.1 (no errno set)
+ *
+ * Supported OS: Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000,
+ * Windows XP, WinCE.
+ *
+ * @ingroup Evil
+ */
+EAPI char *evil_getcwd(char *buffer, size_t size);
 
 #if defined(__CEGCC__) || defined(__MINGW32CE__)
 
===================================================================
RCS file: /cvs/e/e17/proto/evil/src/lib/evil.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- evil.c      26 Apr 2008 16:27:46 -0000      1.6
+++ evil.c      28 Apr 2008 14:34:54 -0000      1.7
@@ -396,6 +396,55 @@
    return tmpdir;
 }
 
+char *
+evil_getcwd(char *buffer, size_t size)
+{
+#if defined(__CEGCC__) || defined(__MINGW32CE__)
+   wchar_t wpath[PATH_MAX];
+   char   *cpath;
+   char   *delim;
+   int     ret = 0;
+
+   if (size <= 0)
+     return NULL;
+
+   ret = GetModuleFileName(GetModuleHandle(NULL), (LPWSTR)&wpath, PATH_MAX);
+
+   if (!ret)
+     return NULL;
+
+   cpath = evil_wchar_to_char(wpath);
+   if (!cpath)
+     return NULL;
+
+   if (strlen(cpath) >= (size - 1))
+     {
+        free(cpath);
+        return NULL;
+     }
+
+   delim = strrchr(cpath, '\\');
+   if (delim)
+     *delim = '\0';
+
+   if (!buffer)
+     {
+        buffer = (char *)malloc(sizeof(char) * size);
+        if (!buffer)
+          {
+             free(cpath);
+             return NULL;
+          }
+     }
+
+   strcpy(buffer, cpath);
+   free(cpath);
+
+   return buffer;
+#else
+   return _getcwd(buffer, size);
+#endif /* ! __CEGCC__ && ! __MINGW32CE__ */
+}
 
 #if defined(__CEGCC__) || defined(__MINGW32CE__)
 



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to