-
November 10th, 2014, 08:53 AM
#1
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.
-
November 10th, 2014, 09:06 AM
#2
Re: How to determine cross platform type during file save?
Does your MFC application work under UNIX?
Victor Nijegorodov
-
November 10th, 2014, 10:41 AM
#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.
-
November 10th, 2014, 11:03 AM
#4
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.
-
November 10th, 2014, 11:47 AM
#5
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.
-
November 10th, 2014, 12:03 PM
#6
Re: How to determine cross platform type during file save?
Sorry, with further thought my original suggestion would not work.
-
November 10th, 2014, 04:17 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|