Finding out with wxWidgets: Is this a writeable directory? - directory

I have a wxFilenName mydir that should point to a writeable directory. Ultimately, mydir has been obtained via mydir=otherfilename.GetPath() (though via some disgressions maybe). Assuming that mydirrefers to (on a Windows box) C:\foo\bar, I need to ensure that C:\foo\barexists and is a directory (not a file) and I have write permissions (so I might create C:\foo\bar\baz).
What I do is to check mydir.IsOk() && mydir.DirExists() && mydir.IsDirWriteable(), but I suspect this does not do what I want. From reading the wxwidgets docs, I gather that it does distinguish between a wxFileName referencing C:\foo\barin the sense of "the file/dir bar in the directory C:\foo" versus C:\foo\bar in the sense of "the directoy C:\foo\bar and no particular file in it") so that I'd expect my method to work as GetPath()should return such a "pure" directory. However, I suspect (and testing indicates) that my checks really check if C:\foo is a writeable directory ...
What would be a better method (within the wxWidgets framework)? Do I really need to append some dummy filename before performing my checks?

Use wxFileName::DirName() to create an object representing a directory.

Related

Recollindex skipped directory

I have to recoll indexing more than 10000 directories and huge number of files.
My directory structure looks like:
Class1
Class1\Users
Class1\Users\Teachers
Class1\Users\Students
Class2\Users\Teachers
Class2\Users\Students
XXXX\YYYY\Teachers
XXXX\YYYY\Students
...
It is important to don't indexing Students directories.
Where can I set to skip the Students directories on recoll-gui?
I found recoll manual: http://www.lesbonscomptes.com/recoll/usermanual/usermanual.html
and I also found the "skippedPaths" variable, but I don't know the exact format, how can I skipping "Students" directories on the indexing (on recoll-gui).
recoll-gui settings Screenshot
Mod:
Unfortunately, there are "Students" directory everywhere, not only under Users directory. For example there is Student directory under Teacher directory.
Skipped Names is not good, because in the Teacher directory there are documents which called "student-names.xls" and indexing may skipped that document also...
In the GUI, go to the indexing configuration section, and click on the + sign for the Skipped Paths section.
This does not open a file selector because you could conceivably have wildcards in there.
Just copy the path for the Students folder as seen on the Linux machine. You can probably see an example path in the "Top directories" section as you must have added something in there.
There will be no backslashes in the path, of course.
Ok, second try: I now understand that you have many "Students" directories, maybe a huge number. If this is the case, you should probably use the "Skipped Names" parameter instead. Go to "Indexing parameters" - "Local parameters" and just add "Students" to the "Skipped names" list (globally: no need for anything in the "Customised subtrees" section)

autohotkey wildcard read loop

I want one script to command several computers to break up a highly distributable workload. In order to distribute the workload I put half of the task labels in one file, and half of the tasks in another file that i distribute to the computers with google drive (which is why i need different file names). So C:\googledrive\task1.txt and C:\googledrive\task2.txt
The autohotkey command looks like:
loop, read, c:\googledrive\task*.txt
But instead of reading task1.txt, it appears to try to read "task*.txt" as a literal file name, fails, and ends the loop.
Ideas? Thanks.
OK, tried ensuring everything was running with administrator rights (they are) and ensured that the files exist (they do) and no typos in the file path (everything good there). Still wont actually read the file.
There is one bit that I didn't include in the original post part of the file name is actually a variable, so the loop command is actually like:
loop, read, c:\googledrive\%task%*.txt
I just figured that bit was inconsequential.
If i save a different script for each computer, i can go ahead and replace the wildcard with the actual bit, and it works.
so... Im just going to name each file with the computer's name in the file, and change the command to:
loop, read, c:\googledrive\%task%%A_ComputerName%.txt
I do it this way....
Loop, C:\Temp\Source\*.txt ; Lists the next file as A_LoopFileName
{
Loop, read, C:\Temp\Source\%A_LoopFileName% ; process current file
{
IfInString, A_LoopReadLine, abc
{
.......
}
}
}

Flex : Create new folder in zip file

I am using Flex, Flash Builder 4.5 and Extension Builder 2.0.0 and I use the "nochump ziplib" library to generate a ZIP file. I want to create a new folder in created ZIP file, but I can't find such function function in the "nochump" library.
Can anyone please tell me if there is any function to add new folder in a ZIP file or a library which can help me do this?
The directories are not first-class citizens in the ZIP format.
The archive is built from "entries" - plain files with their relative locations to the "central directory" (the "root" of the archive). This means that the ZIP file is composed from entries like "pictures/1.jpg", "doc/old/1.txt" etc. You don't have separate entries for the "pictures", "doc" or "doc/old" directories.
You can't create a new directory directly. Instead of creating a new directory first (such as "newDir") you may want to create a file (entry) inside instead (such as "newDir/1.txt") and "newDir" will appear as directory when you open the resulting ZIP file.
If you insist on having an empty directory in the archive, you may try the hacky way - adding entries like "newDir/." with zero length. But this may not work with your library.
The Wikipedia article for the ZIP format has all the theory explained pretty well.

Where are files written to in R?

If I use the write method, where will these files be written? Example:
write(results, file="myFile.csv", ncolumns=1)
I don't specify a full path so I assume it's writing to some default directory. I checked program files, but it's not there. Suggestions on where to look?
If you type from within your R session:
getwd()
You should be able to retrieve your current working directory, that's the place where the files should be saved to.
You can also choose to set your workspace to a location of your desire:
setwd('C:/Users/.../Documents/R/Scripts')
Files you save will automatically be written to this new location.

System::IO::Directory::GetFiles in c++

I am having trouble in storing the files in a string array from a directory in c++, using System::IO::Directory::GetFiles in c++
Also would like to know if we could copy an entire folder to a new destination/ in c++ like given in http://www.codeproject.com/KB/files/xdirectorycopy.aspx for c#
You can store the file names from a directory in a managed array like this:
System::String ^path = "c:\\";
cli::array<System::String ^>^ a = System::IO::Directory::GetFiles(path);
Console::WriteLine(a[0]);
Console::ReadKey();
As for how would you copy an entire folder... Simply recurse from a given root directory creating each directory and copying the files to the new location. If you are asking for code for this, then please say so, but at least try to figure it out for yourself first (i.e. show me what you have so far).
Check out the file listing program in Boost::FileSystem: http://www.boost.org/doc/libs/1_41_0/libs/filesystem/example/simple_ls.cpp. They iterate over all files, printing the paths, but it's trivial to store them instead.
Assuming you're on Win32, you're looking for the FindFirstFile and FindNextFile APIs.
C/C++ does not define a standard way to do this, though Boost::Filesystem provides a method if you need cross platform support.

Resources