1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-05-11 21:47:12 +02:00
Sandu Liviu Catalin 4a6bfc086c Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface.
Deprecated the external module API. It was creating more problems than solving.
Removed most built-in libraries in favor of system libraries for easier maintenance.
Cleaned and secured code with help from static analyzers.
2021-01-30 08:51:39 +02:00

63 lines
1.2 KiB
C++

//
// dir.cpp
//
// This sample demonstrates the DirectoryIterator, File and Path classes.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DirectoryIterator.h"
#include "Poco/File.h"
#include "Poco/Path.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/Exception.h"
#include <iostream>
using Poco::DirectoryIterator;
using Poco::File;
using Poco::Path;
using Poco::DateTimeFormatter;
using Poco::DateTimeFormat;
int main(int argc, char** argv)
{
std::string dir;
if (argc > 1)
dir = argv[1];
else
dir = Path::current();
try
{
DirectoryIterator it(dir);
DirectoryIterator end;
while (it != end)
{
Path p(it->path());
std::cout << (it->isDirectory() ? 'd' : '-')
<< (it->canRead() ? 'r' : '-')
<< (it->canWrite() ? 'w' : '-')
<< ' '
<< DateTimeFormatter::format(it->getLastModified(), DateTimeFormat::SORTABLE_FORMAT)
<< ' '
<< p.getFileName()
<< std::endl;
++it;
}
}
catch (Poco::Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
return 1;
}
return 0;
}