C++ ::  Creating A New Directory?

May 11, 2013

How do you create a new directory in C++? I would like to do this using the standard library and no external, third party or non standard libraries/headers. I need to do this without calling system() or system("mkdir").

View 7 Replies


ADVERTISEMENT

C++ :: How To Change Directory

Apr 24, 2014

How to change directory in c++ ( windows ) I want to go to the folder "example2" and I delete some files and then return to the original folder c++ - windows

View 7 Replies View Related

C++ :: How To Protect Entire TMP Directory

Mar 13, 2014

The general design of my app work-flow:

My application is processing a large amount of data (approx. 50 - 100 GB of txt data). given the machine regular user usually has, my app is writing some tmp data into a local tmp directory. and this is working just fine until users get comfortable with my software and start changing that content of local tmp dir (while the program is running). which does not give any problems like crashing a program if handled at the right time but produces wrong results in the end. now this is not my problem but i would still like to somehow restrict users from even peeking into the tmp dir. I am just tired of getting emails saying my software is cr.... (maybe it is but i don't think it is because of that)

So is it possible to somehow encrypt the entire dir so that only the program has access to it . it would be even better if the dir could look as some encrypted index file so that when user sees the warning :

"tmp" may be a binary file. See it anyway?

View 6 Replies View Related

C :: How To Get User Home Directory

Oct 20, 2014

I want to obtain the user's home directory. I know it can be done with getenv("HOME"), but if I'll inspect the value of the enviroment variable HOME, it might work when I run it now, but it won't work on Windows, since windows uses HOMEPATH to save the user's home directory.

Is there a different, more cross-platform way to do it?

View 5 Replies View Related

C :: Merging All TXT Files In A Directory

Dec 6, 2013

I'm writing a program to merge all .txt files in a directory. I had the code working and then made small change. It started crashing and I couldn't get it back to working.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>

[Code] ....

It's crashing around the

Code: while(!feof(in)){ .

If I comment that section out, the code still works. But, I know that portion of the code works to copy text from one file to another! It's actually from the Schildt complete C reference and I have tested it several times on it's own.

View 5 Replies View Related

C :: Using Process ID As The Name Of File Directory

Jan 31, 2015

I need my Unix program to generate a directory with a format like this: "hinesro.<pid>". I have some code that mostly works, except for the directory ends up with a question mark on the end, like this: "hinesro.12345?". I need it to just display the directory without this question mark. Here is my code:

Code:

// Using headers sys/types.h, sys/stat.h, unistd.h, and stdio.h
int pid = getpid();
char prefix[] = "hinesro.";
char fileName[0];
sprintf(fileName, "%s%d
", prefix, pid);

[Code]...

View 13 Replies View Related

C++ :: Opening A File Within A Directory

Apr 26, 2013

I have problems opening a file within a directory.

#include <dirent.h>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

[Code] .....

Error Message:
$ ./dirsearch ~/Documents/College/textfiles/
[..]
[yomama.txt]
Error : Failed to open entry file - No such file or directory

Here are my current file permissions:
textfiles$ ls -l
total 8
-rw-rw-rw- 1 jav jav 7 Apr 26 13:14 moretext.txt
-rw-rw-rw- 1 jav jav 10 Apr 26 12:38 yomama.txt

View 6 Replies View Related

C++ :: Listing Files From A Given Directory

Aug 5, 2013

I tried listing files using the code given in "[URL] ..." the program listed all the files present in the current dirctory but if i change the drive and the directory to such as

"C:UsersBaaooDownloadsdirect.h function"

the program does not list files name.

#include <iostream>
#include <dirent.h>
using namespace std;
int main() {

DIR* dir;
dirent* pdir;

[Code] .....

View 1 Replies View Related

C++ :: DLL Search Directory Order

Aug 29, 2013

I was working on a program. "hey if this program were to be published it would be bad for people to see all dll files are in the exe directory"....

So I wondered if there is a way to make compiler see a folder in the same directory with exe file which holds all dll files?

Also look at some programs and saw they have a dll folder which holds dll files....

View 1 Replies View Related

C++ :: Can't Open A Directory In Terminal

Jan 12, 2015

Taking a OS course and my professor gave us files to reference in a directory located at ~agw/class/os/share/proj3. But when I typed this into the terminal I keep getting a permission denied error message.

[lastname@erdos ~]$ ls
dead.letter Desktop Documents Downloads Music Pictures private Public public_html Templates Videos
[lastname@erdos ~]$ ~agw/class/os/share/proj3
/u/sobolev/agw/class/os/share/proj3: Permission denied.
[lastname@erdos ~]$

I'm not sure what I am doing wrong. Ive opened shared directories for this class before and had no issues.

View 1 Replies View Related

C++ :: Cannot Open A Directory In Terminal

Dec 9, 2013

Taking a OS course and my professor gave us files to reference in a directory located at ~agw/class/os/share/proj3. But when I typed this into the terminal I keep getting a permission denied error message.

[lastname@erdos ~]$ ls
dead.letter Desktop Documents Downloads Music Pictures private Public public_html Templates Videos
[lastname@erdos ~]$ ~agw/class/os/share/proj3
/u/sobolev/agw/class/os/share/proj3: Permission denied.
[lastname@erdos ~]$

I've opened shared directories for this class before and had no issues.

View 2 Replies View Related

C/C++ :: Scan A Directory Recursively

Dec 19, 2014

I'm writing a C++ module that is meant to recursively scan a directory and I'm curious what yall think of my strategy.

The program is a music player and so I'm trying to make the directory scanner as lightweight and efficient as I can. I've decided I want to scan the files in two passes- first I just want to get a list of all music files that are found in a directory/subdirectories and then I want to process the list and search for id3s/other tags.

As I'm a scanning the directory, I've decided to store the temporary list in a linked list where each node is containing an array of 100 strings. I did this because I obviously don't know how long the list will be and I from my understanding of the C++ vector class it basically just makes over sized arrays and moves them when it runs out of space. That sounded rather clunky to me, as did a traditional linked list.. I didn't see the point of allocating memory that many times in a row.

View 3 Replies View Related

C/C++ :: Get File List From Directory By Name

Nov 19, 2012

I try to get file names listed by date or name in c. How can i do this.

There is a code: But this gives randomly file names.

DIR *dir;
struct dirent *ent;
    dir = opendir ("c:src");
if (dir != NULL) {  
  /* print all the files and directories within directory */
 
[Code] ....

View 2 Replies View Related

C++ :: Capturing Files In A Directory

Jan 9, 2013

I'm using the following code to capture all files in a directory - but when I pass the "path" var such as "C:SomeDir" ffd.cFileName is just simply "SomeDir" and is seen as a valid folder and no more files are processed.. I'm trying to get the contents in that folder. I'm following this example here - [URL] .....

Code:
bool ListFiles(TCHAR* path) {
HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA ffd;
TCHAR * spec = new TCHAR[_MAX_PATH];
static std::stack<TCHAR*> directories;

[Code] .....

View 14 Replies View Related

C :: GCC Does Not Recognize Lib Location - No Such File Or Directory

Aug 19, 2013

I have my libraries in ../../lib location

and when i try to compile :

gcc -O9 -I ../../include/ -L ../../lib/ -o test test.c thr.o -lm -lthread

I get :

gcc: error: thr.o: No such file or directory

obviously the problem is the library path location but my obj is there

ls -al ../../lib/ | grep thr.o
-rw-rw-r-- 1 xxxxxx xxxxxx 23544 Aug 12 23:03 thr.o

????

View 2 Replies View Related

C :: Error While Reading Files In Directory

Sep 7, 2014

I use this header dirent.h to get list of files in directory

[URL] .....

I am using code::blocks on windows XP.

Directory "kernels_source" is placed in project's directory where I am running the code.

Code:

#include "include/types.h"
#include "include/gaussian.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

[Code]....

View 10 Replies View Related

C++ :: Thread Library - No Such File Or Directory

Jul 25, 2014

When I write a code in c++ includes thread library it says "thread:no such file or directory". How can ı use thread library .

I think I should download boost or c++11 but I couldn't do it .

View 4 Replies View Related

C++ :: Trying To Substitute A Variable For File Directory

Jul 1, 2014

I am trying to substitute a variable for the file directory. Here is the error: error: no matching function for call to 'std::basic_ ofstream <char>:: basic_ ofstream(std::string&)'

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
using namespace std;

[code]....

View 2 Replies View Related

C++ ::  Read Only The Oldest File From Directory

Jan 5, 2013

I'm quite new to C++ and got a problem of reading some files from a directory. All files is pure text, and I have no problem in reading these.

My problem is that I always have to read the oldest file without knowing the filename, and then move it to another directory and so on. Is it possible to use the timestamp instead of the filename to access the right file - read it and then move it to another directory?

View 3 Replies View Related

C++ :: Input File Directory From The Console?

Aug 19, 2014

Convert this code into one where you can input the file directory from the console?

#define WIN32_LEAN_AND_MEAN // prevent windows.h from including "kitchen sink"
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{LPCSTR Application = "C:Program FilesWindows Media Playerwmplayer.exe";
// Media file extension must be provided
// Paths are quoted

[Code] ....

This code works but the directory can only be changed from the code not the console.

View 2 Replies View Related

C++ :: Parse The Root Directory Of FAT32?

Dec 27, 2013

I'm trying to parse the root directory of FAT32 in order to get a dir list in the root folder.

So I need to go over all the directory entries in the root directory and parse them.

My problem is that I don't know when to stop the iteration - How to get the size of the root directory?

I noticed that there is a byte in the boot sector - the number of the entries in the root - but in FAT32 the value is always 0, So how can i get the size of the directory?

View 1 Replies View Related

C++ :: Get User Name And Surname In Active Directory?

Sep 11, 2013

I have a logined user and my running program as system process (not user process).

I want to get user name and surname from AD.

1. GetUserName() dont useful becouse it gets name for current process owner(for SYSTEM in my case).

2. There are userLogin, userName, userSurname and userDisplayedName in user properties of AD. Its possible to get userDisplayedName by NetUserGetInfo(), but
I want to know is it possible to get userName and userSurname?

View 1 Replies View Related

Visual C++ :: Accessing User Directory In Win 7 Pro?

Jul 12, 2013

I have been using the code below to extract the current user directory in order to read and write to certain files, presumeably independent of whether or not the user has administrative privileges. This has been necessitated in Win 7 because applications installed in the customary C:/Program Files(x86)/ are not allowed full access to files in the installed app root directory. This was working just fine until just this week when suddenly, for the first time, I found that the user directory retrieved was different when the app was run without administrative privileges in 'Start without debugging' configuration, both in Debug and Release configuration. Note that I have tested the identical app on Win2K and Vista and in neither case is it a problem on those OS machines. More mysterious is the fact that this ONLY happens on Win7 (VS2010 Ultimate) when run in the IDE. Run from the windows explorer double click, the app runs just fine in release and debug mode and monitoring the debug version using DbgView indicates that the expected 'Roaming' User directory is retrieved.

For example:

- without debugging (both Debug and Release configuration) the code below produces:

m_csUserDirectory =: C:UsersMPLIAMAppDataLocalPliaTechUeberKrypt

- with debugging (both Debug and Release configuration) the code below produces:

m_csUserDirectory =: C:UsersMPLIAMAppDataRoamingPliaTechUeberKrypt

Either this has been the situation from the outset and I just never noticed it (hard to imagine as I've been on this project for 6 months with 50+ builds), a recent Windows update has changed things, a bug, or I'm just plain stupid (not hard to imagine at all).

From a practical standpoint, if this is the way things are to be, my installer will need to install necessary files in both user directories and the app will need to access both depending upon user privileges.

Code:
/// This routine retrieves the process's environment block
/// using GetEnvironmentStrings, parses that block pointed to
/// by the generic international text pointer LPTCH, and returns
/// the requested string lpszVarStr as a string.
/// Note that the block lpvEnv environment variable substrings
/// are separated by NULL byte, and the block is terminated by a NULL byte.
/// The header files <windows.h>, <tchar.h>, <stdio.h>, <string>, and
/// <iostream> need to be included.

[code].....

View 5 Replies View Related

C++ :: Output Only Few Files Using Regex From Current Directory

Nov 20, 2013

I'm trying to output only a few files, using regex, from the current directory, this is my main code:

Code:
// main.cpp
{
char * _dir = new char[MAX_PATH];
getcwd(_dir, MAX_PATH);
unique_ptr<CExtractor> _ptr(new CExtractor(_dir));
delete[] _dir;
}

Code:
// CExtractor.cpp
DIR *pdir = NULL;
struct dirent *pent = NULL;
pdir = opendir(_cwd.c_str());
while ((pent = readdir(pdir)) && (pent->d_type != DT_DIR)) {
if (regex_match(pent->d_name, regex(".(in|txt)$"), std::regex_constants::icase)) {
cout << pent->d_name << endl;
}
}
closedir(pdir);

My code is compiled correctly, but when I run my binary, nothings is outputed..here are my files in the current directpory:

aclocal.m4 config.guess config.status depcomp m4 NEWS
AUTHORS config.h config.sub INSTALL Makefile README
autom4te.cache config.h.in configure install-sh Makefile.am src
ChangeLog config.h.in~ configure.ac libtool Makefile.in stamp-h1
compile config.log COPYING ltmain.sh missing

I have a few "in" files

View 1 Replies View Related

C++ :: Implement Hashing Of Text Files In Directory

Feb 9, 2014

Writ a program to implement hashing of text files in a directory to find files with the same content?

View 1 Replies View Related

C++ :: Header File - Compiler Error Before Directory

May 18, 2014

I'm trying to compile this code which is a header file.

#ifndef CUBEMAP_H_INCLUDED
#define CUBEMAP_H_INCLUDED
#include "Texture.h"
#include <string>
class CubeMap : Texture {

[Code] ....

But I get the following error:

|9|error: expected ')' before 'Directory'|

How can i resolve this?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved