CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2014
    Posts
    3

    Question How to determine cross platform type during file save?

    Hello,
    I am overriding OnSaveDocument in my MFC document class to strip out the carriage returns when saving my app's document to a UNIX file system but not when the user is saving a file to a Windows file system.

    Is there a way to determine if the lpszPathName in OnSaveDocument(LPCTSTR lpszPathName) is a UNIX or Windows file system?

    Note, I want to avoid hard coding server names and I want to avoid overriding the FileSave dialog and forcing the user to select Windows or UNIX.


    Thanks.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to determine cross platform type during file save?

    Does your MFC application work under UNIX?
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2014
    Posts
    3

    Re: How to determine cross platform type during file save?

    No. My MFC app is a Windows app and runs on a Windows OS. My app is a FORTRAN editor program I wrote. However, I have access to my UNIX FORTRAN source files via a samba share. I can open and edit these fortran source files located on a UNIX file system with my Windows MFC app. I just need to fix the ^M problem when saving back to the UNIX file system. I know how to fix the ^M problem but I'm wondering if there is a way to query the file system to determine if it is UNIX or Windows based. I want to be able to work with FORTRAN source files on either Windows or UNIX and so I need to be able to handle save to either system.

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: How to determine cross platform type during file save?

    Maybe you can detect whether lpszPathName is a network path, and then ask user to select line-end type. If file name is local, save with Windows line-ends.

  5. #5
    Join Date
    Nov 2014
    Posts
    3

    Re: How to determine cross platform type during file save?

    Thanks for the idea but almost all of our paths are network paths. Rarely do we have files locally on our workstations. Also, most people map drive letters to the most frequently used network paths so I need to be able to handle that situation.

  6. #6
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

    Re: How to determine cross platform type during file save?

    Sorry, with further thought my original suggestion would not work.

  7. #7
    Join Date
    Nov 2003
    Posts
    1,902

    Re: How to determine cross platform type during file save?

    I would detect the line ending style when opening an exist files and preserve it. When saving a new file, you could have an option settings for the default ending style to use or just ask the user when saving. It would also make sense to have a per-document setting somewhere to toggle the current ending style in the document.

    gg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured