📄 directorywater.cpp
字号:
// DirectoryWater.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "DirectoryWatcher.h"
#include <time.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
int main(int argc, char* argv[])
{
char buffer[128];
CDirectoryWatcher* dirw=new CDirectoryWatcher;
if (dirw->Start("./"))
{
cout<<"start succesful"<<endl;
}
else
cout<<"start faulure"<<endl;
//Sleep(1000*10);
memset(buffer,0,sizeof(buffer));
while(true){
cin>>buffer;
if (!strcmp("quit",buffer))
break;
if (!strcmp("get",buffer))
cout<<"Answer: \t"<<dirw->Get().c_str()<<endl;
if (!strcmp("status",buffer)){
cout<<"Answer: \t";
if(dirw->Status())
cout<<"true"<<endl;
else
cout<<"false"<<endl;
}
if (!strcmp("set",buffer)){
memset(buffer,0,sizeof(buffer));
cin>>buffer;
dirw->Set(buffer);
dirw->Start();
}
if (!strcmp("stop",buffer))
dirw->Stop();
if (!strcmp("start",buffer)){
if (dirw->Start())
cout<<"Start Success!"<<endl;
else
cout<<"start faulure"<<endl;
}
memset(buffer,0,sizeof(buffer));
}
dirw->Stop();
cout<<"stop over"<<endl;
Sleep(1000);
delete dirw;
//
/*
char tmpbuf[128], ampm[] = "AM";
time_t ltime;
struct _timeb tstruct;
struct tm *today, *gmt, xmas = { 0, 0, 12, 25, 11, 93 };
_tzset();
// Display operating system-style date and time. //
_strtime( tmpbuf );
printf( "OS time:\t\t\t\t%s\n", tmpbuf );
_strdate( tmpbuf );
printf( "OS date:\t\t\t\t%s\n", tmpbuf );
// Get UNIX-style time and display as number and string. //
time( <ime );
printf( "Time in seconds since UTC 1/1/70:\t%ld\n", ltime );
printf( "UNIX time and date:\t\t\t%s", ctime( <ime ) );
// Display UTC. //
gmt = gmtime( <ime );
printf( "Coordinated universal time:\t\t%s", asctime( gmt ) );
// Convert to time structure and adjust for PM if necessary. //
today = localtime( <ime );
if( today->tm_hour > 12 )
{
strcpy( ampm, "PM" );
today->tm_hour -= 12;
}
if( today->tm_hour == 0 ) // Adjust if midnight hour. //
today->tm_hour = 12;
// Note how pointer addition is used to skip the first 11
* characters and printf is used to trim off terminating
* characters.
//
printf( "12-hour time:\t\t\t\t%.8s %s\n",
asctime( today ) + 11, ampm );
// Print additional time information. //
_ftime( &tstruct );
printf( "Plus milliseconds:\t\t\t%u\n", tstruct.millitm );
printf( "Zone difference in seconds from UTC:\t%u\n",
tstruct.timezone );
printf( "Time zone name:\t\t\t\t%s\n", _tzname[0] );
printf( "Daylight savings:\t\t\t%s\n",
tstruct.dstflag ? "YES" : "NO" );
// Make time for noon on Christmas, 1993. //
if( mktime( &xmas ) != (time_t)-1 )
printf( "Christmas\t\t\t\t%s\n", asctime( &xmas ) );
// Use time structure to build a customized time string. //
today = localtime( <ime );
// Use strftime to build a customized time string. //
strftime( tmpbuf, 128,
"Today is %A, day %d of %B in the year %Y.\n", today );
printf( tmpbuf );
*/
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -