Skip to content

Commit

Permalink
Ready to Go
Browse files Browse the repository at this point in the history
Better Organised
Compiled for both MacOS and Windows
Accept Destination as Argument
  • Loading branch information
manngo committed Jul 3, 2019
1 parent 010e062 commit 266400a
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 36 deletions.
Binary file added bin/shendmail
Binary file not shown.
Binary file added bin/shendmail.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions notes/win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Compiling on Windows with MinGW

set PATH=C:\mingw\bin;%PATH%;
gg++ shendmail.cpp -o shendmail.exe
Binary file removed shendmail
Binary file not shown.
36 changes: 0 additions & 36 deletions shendmail.cpp

This file was deleted.

File renamed without changes.
51 changes: 51 additions & 0 deletions source/shendmail.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Platform
================================================
This works as is on MacOS and Linux.
If you are using Windows the #ifdef below should
detect it, and the POSIX function realpath() is
faked with the Windows function _fullpath()
================================================ */
#ifdef _WIN32
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
#endif

// Includes

#include <fstream>
#include <string>
#include <iostream>
#include <stdio.h>
#include <libgen.h>

using namespace std;

// main

int main(int argc, char *argv[]) {
// CWD
char buffer[FILENAME_MAX];
realpath(argv[0],buffer);
string cwd=dirname(buffer);

// cout<<cwd<<"\n";

// Define Input
string input;

// Define Output
string outputFile=cwd+"/mail.txt";
if(argc>1) outputFile=argv[1];
ofstream output;
output.open(outputFile,ofstream::out | ofstream::app | ofstream::binary);

// cout<<outputFile<<"\n";

// Do the thing …
while(getline(cin,input)) {
output<<input;
output<<"\n";
}
output<<"================================================\n\n";

return 0;
}
File renamed without changes.

0 comments on commit 266400a

Please sign in to comment.