Subject: Dealing with Unix file systems

From: Adrian Tulloch <[email-masked]>
Date: Tue, 9 Jul 1996 10:32:24 +1000

I guess that we're all familiar with the problems caused by different 
line-end conventions in the Dos and Unix worlds: Dos uses CR-LF to mark the 
end of a line, and Unix uses just LF.

NT Emacs currently takes an "all or nothing" approach to this problem.  You 
can say that  *all* your file systems are unix, with 
(using-unix-filesystems t), otherwise they're *all* assumed to be dos-like 
systems.  This is something that I guess many people would like to see 
fixed, however, it's likely that different people will want this fixed in 
different ways.

To start the ball rolling I'll tell you how I've fixed the problem for 
myself.  If you see a better way, let me know, and I'll implement, 
otherwise I'll submit my code to Andrew and Geoff for Emacs 19.32.

There's a useful API in Win32 called GetVolumeInformation().  This, amongst 
other things, returns a string representing the type of the file system. 
 I've  put a wrapper around this function, and made it a Lisp primitive:
	(win32-get-volume-type "c:\\")
returns "NTFS",  for a NTFS file system, "FAT" for a FAT file system, and, 
more importantly, "Samba" if the drive is mapped to a Unix share via Samba. 
 After this lisp function is available, it's easy to add a write-file hook 
which looks at the destination we're saving the file in, and saves it as a 
Dos or unix text file, depending on the type of the file system.  There's 
no need for the user to maintain a table of drive-letter file system 
correspondences; Emacs can work out the type of file system for itself.

Does anyone see any problems with this approach?  Personally, I only see 
one problem.  It's possible that GetVolumeInformation() doesn't return 
useful results for non-Samba unix file systems, such as systems mounted 
with an NFS client for NT.  If the API doesn't return a unique string for 
these file systems, Emacs won't be able to work out that these disks are 
unix disks.  However, I don't' have access to any of these more exotic file 
systems, so I can't test this.  If anybody out there is using this sort of 
configuration, I'd appreciate it if you could send me a reply, so we can 
work out how to test this.

As I said earlier, if you can see a better way to deal with this problem, 
let me know, and I'll change my code.  Otherwise I'll send my current fix 
to Geoff and Andrew.

Adrian