- /* Find path without the filename.
- * I.e. everything after the last / is a "filename".
- * OK, maybe it is a directory name, but we treat it like
- * a filename. If we don't find a / then the whole name
- * must be a path name (e.g. c:).
- */
- for (p=l=ar->fname; *p; p++) {
- if (*p == '/') {
- l = p; /* set pos of last slash */
- }
- }
- if (*l == '/') { /* did we find a slash? */
- l++; /* yes, point to filename */
- } else { /* no, whole thing must be path name */
- l = p;
- }
-
- /* If filename doesn't exist (i.e. root directory), we
- * simply create a blank name consisting of a single
- * space. This makes handling zero length filenames
- * easier.
- */
- fnl = p - l;
- if (fnl > 255) {
- Jmsg(mdb->jcr, M_WARNING, 0, _("Filename truncated to 255 chars: %s\n"), l);
- fnl = 255;
- }
- if (fnl > 0) {
- strncpy(file, l, fnl); /* copy filename */
- file[fnl] = 0;
- } else {
- file[0] = ' '; /* blank filename */
- file[1] = 0;
- fnl = 1;
- }
-
- pnl = l - ar->fname;
- if (pnl > 255) {
- Jmsg(mdb->jcr, M_WARNING, 0, _("Path name truncated to 255 chars: %s\n"), ar->fname);
- pnl = 255;
- }
- strncpy(spath, ar->fname, pnl);
- spath[pnl] = 0;
-
- if (pnl == 0) {
- Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), ar->fname);
- Jmsg(mdb->jcr, M_ERROR, 0, "%s", mdb->errmsg);
- spath[0] = ' ';
- spath[1] = 0;
- pnl = 1;
- }
-
- Dmsg1(100, "spath=%s\n", spath);
- Dmsg1(100, "file=%s\n", file);