Skip to content

Commit

Permalink
made nsm Windows compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ham committed May 13, 2019
1 parent d2c7aa5 commit 8c3fddf
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
2 changes: 2 additions & 0 deletions DateTimeInfo.h
Expand Up @@ -2,9 +2,11 @@
#define DATE_TIME_INFO_H_

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
#include <time.h>

//information about date and time
/*
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -41,7 +41,7 @@ install:
chmod 755 nsm
sudo mv nsm /usr/local/bin

auto-highlighting:
linux-gedit-highlighting:
chmod 644 html.lang
sudo mv html.lang /usr/share/gtksourceview-3.0/language-specs/html.lang

Expand All @@ -54,3 +54,6 @@ linux-install:
clean:
rm -f $(objects)

clean-all:
rm -f $(objects) nsm

6 changes: 5 additions & 1 deletion Path.cpp
Expand Up @@ -89,7 +89,11 @@ bool Path::ensurePathExists() const
{
cDir += dDeque[d];
//std::cout << "making sure " << cDir << " exists " << std::endl;
mkdir(cDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#ifdef _WIN32
_mkdir(cDir.c_str()); //windows specific
#else //unix
mkdir(cDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); //unix/linux/osx specific
#endif // _WIN32
}

if(file.length())
Expand Down
5 changes: 5 additions & 0 deletions Path.h
Expand Up @@ -7,6 +7,11 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>

#ifdef _WIN32
#include <direct.h>
#endif

#include "Directory.h"
#include "Filename.h"
Expand Down
28 changes: 25 additions & 3 deletions nsm.cpp
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char* argv[])

if(cmd == "commands")
{
std::cout << " --------- available commands --------------------------------------" << std::endl;
std::cout << "+--------- available commands --------------------------------------+" << std::endl;
std::cout << "| nsm commands | lists all nsm commands |" << std::endl;
std::cout << "| nsm config | lists config settings |" << std::endl;
std::cout << "| nsm init | input: initialise managing a site |" << std::endl;
Expand All @@ -66,7 +66,7 @@ int main(int argc, char* argv[])
std::cout << "| nsm build-all | builds all tracked pages |" << std::endl;
std::cout << "| nsm new-title | input: page-name new-title |" << std::endl;
std::cout << "| nsm new-template | input: page-name template-path |" << std::endl;
std::cout << " -------------------------------------------------------------------" << std::endl;
std::cout << "+-------------------------------------------------------------------+" << std::endl;

return 0;
}
Expand All @@ -77,11 +77,17 @@ int main(int argc, char* argv[])
{
//ensures nsm is not managing a site from this directory or one of the ancestor directories
std::string parentDir = "../",
rootDir = "/",
rootDir = "C:\\",
owd = get_pwd(),
pwd = get_pwd(),
prevPwd;

#ifdef _WIN32
rootDir = "C:\\";
#else //unix
rootDir = "/";
#endif // _WIN32

if(std::ifstream(".siteinfo/pages.list") || std::ifstream(".siteinfo/nsm.config"))
{
std::cout << "nsm is already managing a site in " << owd << " (or an accessible ancestor directories)" << std::endl;
Expand Down Expand Up @@ -127,6 +133,10 @@ int main(int argc, char* argv[])
//adds read and write permissions to pages list file
chmod(pagesListPath.str().c_str(), 0666);

#ifdef _WIN32
system("attrib +h .siteinfo");
#endif // _WIN32

std::ofstream ofs(".siteinfo/nsm.config");
ofs << "contentDir content/" << std::endl;
ofs << "contentExt .content" << std::endl;
Expand Down Expand Up @@ -160,6 +170,10 @@ int main(int argc, char* argv[])
//adds read and write permissions to pages list file
chmod(pagesListPath.str().c_str(), 0666);

#ifdef _WIN32
system("attrib +h .siteinfo");
#endif // _WIN32

std::ofstream ofs(".siteinfo/nsm.config");
ofs << "contentDir content/" << std::endl;
ofs << "contentExt .content" << std::endl;
Expand Down Expand Up @@ -538,6 +552,10 @@ int main(int argc, char* argv[])
//adds read and write permissions to pages list file
chmod(pagesListPath.str().c_str(), 0666);

#ifdef _WIN32
system("attrib +h .siteinfo");
#endif // _WIN32

std::ofstream ofs(".siteinfo/nsm.config");
ofs << "contentDir content/" << std::endl;
ofs << "contentExt .content" << std::endl;
Expand Down Expand Up @@ -1069,6 +1087,10 @@ int main(int argc, char* argv[])
//adds read and write permissions to pages list file
chmod(pagesListPath.str().c_str(), 0666);

#ifdef _WIN32
system("attrib +h .siteinfo");
#endif // _WIN32

std::ofstream ofs(".siteinfo/nsm.config");
ofs << "contentDir content/" << std::endl;
ofs << "contentExt .content" << std::endl;
Expand Down

0 comments on commit 8c3fddf

Please sign in to comment.