Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FreeburnHelper.cpp
Upload User: cnxinhai
Upload Date: 2013-08-06
Package Size: 265k
Code Size: 6k
Category:
DVD
Development Platform:
Visual C++
- /* This is a set of helper methods used in FreeBurn that provide some
- * useful functionality but only support the program, they do not provide
- * any actual "real" functionality
- *
- * Copyright (C) 2001, 2002 Adam Schlag
- */
- /*
- * FreeBurn Software License
- * (based on the Apache Software License)
- *
- * Version 1.1
- *
- * Copyright (c) 2001, 2002 The FreeBurn Project. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. The end-user documentation included with the redistribution, if any, must
- * include the following acknowledgment:
- *
- * "This product includes software developed by the FreeBurn
- * Project (http://freeburn.sourceforge.net/)."
- *
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "FreeBurn" and "FreeBurn Project" must not be
- * used to endorse or promote products derived from this software
- * without prior written permission. For written permission, please
- * contact aschlag@users.sourceforge.net.
- *
- * 5. Products derived from this software may not be called "FreeBurn",
- * nor may "FreeBurn" appear in their name, without prior written
- * permission of the FreeBurn Project.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE FREEBURN PROJECT OR ITS
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the FreeBurn Project. For more
- * information on the FreeBurn Project and FreeBurn, please see
- * <http://freeburn.sourceforge.net/>.
- *
- * This software is distributed with software that is released under the GNU
- * General Public License (GPL). You can find the terms of this license in the
- * file GPL.txt distributed in this package. You can find information on the
- * software distributed with this package in the file PROGRAMS.txt.
- */
- #include <fx.h>
- #include "FreeburnHelper.h"
- #include "FreeburnDefs.h"
- int FreeburnHelper::winPathToUnixPath(const FXString& winPath, FXString& unixPath)
- {
- // first, get the absolute path of the winPath (this is being
- // used because FXFile::simplify for some reason was adding too
- // many backslashes, and getting the absolute path just makes
- // the command look better)
- unixPath = FXFile::absolute(winPath);
- // second, replace each backslash with a forward slash
- unixPath.substitute('\', '/');
- // third, change the Windows drive letter notation to they Cygwin directory notation
- // i.e. change C: to /cygdrive/C
- if (unixPath.count(':') != 0) // The beginning of the string is a drive name, like "C:"
- {
- FXint pos = unixPath.findf(':'); // find the location of ':'
- unixPath.remove(pos); // remove the ':'
- unixPath.prepend("/cygdrive/"); // insert "/cygdrive/" for the Cygwin directory notation
- }
- // finally, insert a backslash ('') in front of any space
- // in a path, so it is understood by a UNIX shell.
- // First, we get the index of the first space (' ')
- FXint index = unixPath.findf(' ', 0);
- // now loop until index is > -1, or there are no other
- // spaces to fix
- while (index > -1)
- {
- unixPath.insert(index, '\'); // insert a backslash in front of a space
- index = unixPath.findf(' ', (index+2)); // find the next space starting 2 characters
- // past where the backslash is inserted
- }
- return 1;
- }
- FXbool FreeburnHelper::saveNewTextFile(FXWindow* owner, FXString& fileContents)
- {
- FXString fileName;
- // a file dialog to specify the name and location to save the file
- FXFileDialog saveDialog(owner,"Save File"); // the new save dialog
- saveDialog.setSelectMode(SELECTFILE_ANY); // the file select mode
- saveDialog.setPatternList("All Files (*.*)"); // the pattern list for files
- if(!saveDialog.execute()) return FALSE; // execute the dialog and get a file name
- fileName = saveDialog.getFilename(); // get the name of the file
- if(FXFile::exists(fileName)) // if the file exists, ask if we want to overwrite
- {
- if(MBOX_CLICKED_NO==FXMessageBox::question(owner,MBOX_YES_NO,"Overwrite File",
- "Overwrite existing file: %s?",fileName.text())) return FALSE;
- }
- FXFileStream outputFile; // a new file stream
- if(outputFile.open(fileName, FXStreamSave)) // if we can open the stream...
- {
- outputFile << fileContents.text(); // ...write the text...
- outputFile.close(); // ...and close the stream
- }
- else return FALSE; // return false if we didn't open the stream
- return TRUE; // everything's okay, so return
- }