1

I've got a txt file that has Unix newlines and needs to have Windows newlines. I try to do unix2dos filename.txt but I get Unix2Dos: Can't stat 'filename.txt'. In fact, it says Can't stat 'xxx' for whatever xxx I feed it.

I've tried to google this error but can't find anything relevant to my situation, and no general description of what might cause this error.

If it makes any difference, I'm on Windows 7 and running some version of Unix2Dos that I've downloaded.

4
  • Is that Cygwin, MSys, Services for Unix or other posix layer for windows?
    – Jan Hudec
    Sep 10, 2014 at 8:33
  • I'm not sure what your question means, but if it means what I think it means, I have no idea of the answer. :) I don't think I've installed Cygwin, but I don't know how to find out. I'm running Unix2Dos from the standard windows command prompt. The executable resides in a directory where I keep utilities like that.
    – gibson
    Sep 10, 2014 at 8:58
  • Where did you get the utility from?
    – Jan Hudec
    Sep 10, 2014 at 9:16
  • I don't remember. But it appears it's Dropbox that's messing with directory permissions.
    – gibson
    Sep 10, 2014 at 9:54

1 Answer 1

1

The error comes from this part (lookig at source code of Unix2Dos):

    if (stat (path=*++argv, &s_buf) != -1)   
    {   
        printf ("Unix2Dos: Cleaning file %s ...\n", path);   
        if (u2dos (path))   
        {   
            fprintf (stderr, "Unix2Dos: Problems cleaning file %s.\n", path);   
            exit (1);   
        }   
    }   
    else   
    {   
        fprintf (stderr, "Unix2Dos: Can't stat '%s'.\n", path);   
        exit (1);   
    }   

That means, the stat function can't be executed:

These functions return information about a file, in the buffer pointed to by stat. No permissions are required on the file itself, but—in the case of stat(), fstatat(), and lstat()—execute (search) permission is required on all of the directories in pathname that lead to the file.


[EDITED by @ibson]

In this particular case, the file resided in a sub-directory of a Dropbox directory. After moving the file elsewhere, Unix2Dos was able to do its job just fine. Apparently, Dropbox on Windows 7 does something with directory permissions.

2
  • 1
    The part about 'all of the directories' got me thinking. It turns out, having the file in a Dropboxed directory was messing things up for me. I edited your answer to feature this case-specific detail more prominently than would have been the case if I only left a comment. I hope that's ok? :)
    – gibson
    Sep 10, 2014 at 8:56
  • It's OK, thank you for that - I have marked your part with [EDITED] Sep 10, 2014 at 8:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .