- f = 1;
-
- if (f)
- {
- if (dest - fn2 >= maxlen)
- {
- int ofs = dest - fn2;
- maxlen *= 2;
- fn2 = xrealloc (fn2, maxlen + 1);
- dest = fn2 + ofs;
- }
- *dest++ = c;
- }
- }
-}
-#elif defined (__WIN32__)
-char *
-fn_normalize (const char *fn1)
-{
- DWORD len;
- DWORD success;
- char *fn2;
-
- /* Don't change special file names. */
- if (fn_is_special (file_name))
- return xstrdup (file_name);
-
- /* First find the required buffer length. */
- len = GetFullPathName (fn1, 0, NULL, NULL);
- if (!len)
- {
- fn2 = xstrdup (fn1);
- return fn2;
- }
-
- /* Then make a buffer that big. */
- fn2 = xmalloc (len);
- success = GetFullPathName (fn1, len, fn2, NULL);
- if (success >= len || success == 0)
- {
- free (fn2);
- fn2 = xstrdup (fn1);
- return fn2;
- }
- return fn2;
-}
-#elif __BORLANDC__
-char *
-fn_normalize (const char *fn1)
-{
- char *fn2 = _fullpath (NULL, fn1, 0);
- if (fn2)
- {
- char *cp;
- for (cp = fn2; *cp; cp++)
- *cp = toupper ((unsigned char) (*cp));
- return fn2;
- }
- return xstrdup (fn1);
-}
-#elif __DJGPP__
-char *
-fn_normalize (const char *fn1)
-{
- char *fn2 = xmalloc (1024);
- _fixpath (fn1, fn2);
- fn2 = xrealloc (fn2, strlen (fn2) + 1);
- return fn2;
-}
-#else /* not Lose32, Unix, or DJGPP */
-char *
-fn_normalize (const char *fn)
-{
- return xstrdup (fn);
-}
-#endif /* not Lose32, Unix, or DJGPP */
-
-/* Returns the directory part of FILE_NAME, as a malloc()'d
- string. */
-char *
-fn_dir_name (const char *file_name)
-{
- const char *p;
- char *s;
- size_t len;
-
- len = strlen (file_name);
- if (len == 1 && file_name[0] == '/')
- p = file_name + 1;
- else if (len && file_name[len - 1] == '/')
- p = buf_find_reverse (file_name, len - 1, file_name + len - 1, 1);
- else
- p = strrchr (file_name, '/');
- if (p == NULL)
- p = file_name;
-
- s = xmalloc (p - file_name + 1);
- memcpy (s, file_name, p - file_name);
- s[p - file_name] = 0;
-
- return s;
-}