home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-31 | 1.6 KB | 58 lines | [TEXT/ttxt] |
- SUMMARY
- _______
-
- Have you ever wished the barrier to entry to programming on the mac was not so
- high?
- Did you ever sit down and hack for hours just to get a simple utility such as a
- file
- filter going on the mac ? If so, drag and drop C++ is for you.
-
- The basic idea is that files you drag and drop onto your application are
- immediately
- available as files which you can use standard C and C++ functions to operate on.
-
- For example here is an application which gives the size of any file you drop on
- it:
-
- #include <stdio.h>
- #include <sys/stat.h>
-
- main(int argc, char **argv)
- {
- char name[99];
- struct stat statbuf;
- strcpy(name, argv[argc-1]);
- if (stat(name, &statbuf)) perror(name),exit(-2);
- printf("File size = %d bytes\n", statbuf.st_size);
- exit(0);
- }
-
- and here is a program that performs a similar function, using C++
- iostreams instead of printf()
-
- #include <stdlib.h>
- #include <iomanip.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-
- main(int argc, char **argv)
- {
- char name[99];
- struct stat statbuf;
- strcpy(name, argv[argc-1]);
- if (stat(name, &statbuf)) perror(name),exit(-2);
- cout << "File size = ";
- cout << dec << statbuf.st_size << " bytes(" ;
- cout << hex << statbuf.st_size << " hex)" ;
- cout << endl;
- }
-
- The clever bit is that the C/C++ compiler itself is also a drag-and-drop file
- filter,
- so to generate your new application, you just drop the source code on the 'gcc'
- application !
-
- Be sure to read the file INSTALLATION and the file COPYING (especially the section
- NO WARRANTY) before using this program.
-
-