FAT32 volumes: How to get 8.3 short path and file names?

This is a discussion on FAT32 volumes: How to get 8.3 short path and file names? within the Linux Programming forums, part of the Platform Specific Boards category; Hi, is there a way to get the the 8.3 filename for a file that is stored on a mounted ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    2

    Question FAT32 volumes: How to get 8.3 short path and file names?

    Hi,

    is there a way to get the the 8.3 filename for a file that is stored on a mounted FAT32 volume?

    I know that reading directory content can be done with opendir/readdir/closedir commands but that does not help much here.

    The reason for getting the 8.3 filenames is that these file names need to be stored in an old proprietary legacy file format which can only handle 8.3 path and file names.

    Many thanks,
    Fredo

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    From the "man 8 mount" manual page
    shortname=lower|win95|winnt|mixed

    Defines the behaviour for creation and display of filenames which fit into 8.3 characters. If a long name for a file exists, it will always be
    preferred display. There are four modes: :

    lower Force the short name to lower case upon display; store a long name when the short name is not all upper case. This mode is the default.

    win95 Force the short name to upper case upon display; store a long name when the short name is not all upper case.

    winnt Display the shortname as is; store a long name when the short name is not all lower case or all upper case.

    mixed Display the short name as is; store a long name when the short name is not all upper case.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    2
    Thanks.

    Being rather new to *NIX programming, I still don't know how to deal with that in my program: If a FAT volume is already mounted with the default mode=lower, how can I retrieve the short file names from within my C program? Should my program try to unmount the volume and remount it with mode=mixed? This would irritate my users a lot, I think
    Or is there a vfat API function that gives me the short file name for a given long file name (like in Windows)?

    Thanks again,
    Fredo

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,691
    I'm not sure if it would work, but you could try to convert the long file names to 8.3 yourself.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mac - File locking with fcntl() fails on shared volumes!?
    By idelovski in forum Linux Programming
    Replies: 3
    Last Post: 11-10-2008, 07:37 PM
  2. Accessing EXT2 from FAT32
    By shankar96 in forum Linux Programming
    Replies: 1
    Last Post: 05-14-2004, 07:47 AM
  3. Ntfs to Fat32 Without Format?
    By drdroid in forum Tech Board
    Replies: 8
    Last Post: 01-17-2004, 11:33 AM
  4. using path names
    By AmazingRando in forum C Programming
    Replies: 4
    Last Post: 09-23-2003, 07:09 PM
  5. is there a way to write the file names in a folder in a text file?
    By Commander in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 08-15-2002, 06:11 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21