directory

How to create file inside a directory using C

ⅰ亾dé卋堺 提交于 2019-12-18 09:00:28
问题 I am trying to create a directory and a file inside the directory. Below is my code in C, but when I try to compile it, I got this error: invalid operands to binary / (have ‘const char *’ and ‘char *’) char *directory = "my_dir"; struct stat dir = {0}; if(stat(directory, &dir) == -1) { mkdir(directory, 0755); printf("created directory testdir successfully! \n"); } int filedescriptor = open(directory/"my_log.txt", O_RDWR | O_APPEND | O_CREAT); if (filedescriptor < 0) { perror("Error creating

Android: targeted res folders for debugging in eclipse

左心房为你撑大大i 提交于 2019-12-18 08:00:07
问题 I have a project which I have a number of different branded versions, with two different res folders. ie. res-customer1, res-customer2 Using Maven build profiles I can easily build the project using the specified res folder. However when it comes to eclipse its another story. What I want to do is to have a setting so that I can specify the res folder that I want, whilst debugging in eclipse. Anyone know how I can do this? My current work around is to copy the res-customer1 folder into the res

Git does not recognize new folder adds and its sub directories

爷,独闯天下 提交于 2019-12-18 07:05:34
问题 I have: dirA/dir1 dirA/dir2 dirA has been added and I see it on the browser - when I click " dirA ", I see dir1 and dir2 , grayed out like I have explained below. dir1 and dir2 , both have more than one sub-directories and files. git add dir1 git commit -m "..." I get a message " On branch master, nothing to commit, working directory clean " I am not sure why it wont go through and I see those as "grayed out" on the GitHub repo via browser. Can someone help? I saw some similar threads on

Bash scripting: Deleting the oldest directory

偶尔善良 提交于 2019-12-18 06:07:10
问题 I want to look for the oldest directory (inside a directory), and delete it. I am using the following: rm -R $(ls -1t | tail -1) ls -1t | tail -1 does indeed gives me the oldest directory, the the problem is that it is not deleting the directory, and that it also list files. How could I please fix that? 回答1: This is not pretty but it works: rm -R $(ls -lt | grep '^d' | tail -1 | tr " " "\n" | tail -1) 回答2: rm -R "$(find . -maxdepth 1 -type d -printf '%T@\t%p\n' | sort -r | tail -n 1 | sed 's/

R test if a file exists, and is not a directory

喜夏-厌秋 提交于 2019-12-18 05:48:09
问题 I have an R script that takes a file as input, and I want a general way to know whether the input is a file that exists, and is not a directory. In Python you would do it this way: How do I check whether a file exists using Python?, but I was struggling to find anything similar in R. What I'd like is something like below, assuming that the file.txt actually exists: input.good = "~/directory/file.txt" input.bad = "~/directory/" is.file(input.good) # should return TRUE is.file(input.bad)

How do you change the default directory in RStudio (or R)?

天涯浪子 提交于 2019-12-18 05:29:04
问题 I consulted http://www.rstudio.com/ide/docs/using/workspaces and tried the setwd code and clicking on More --> Set as working directory options. However, the next time I closed and opened RStudio, it did NOT change my directory to the one I wanted. How do I set the directory so I don't have change it each time I open RStudio? Thanks. 回答1: Not sure if this is what you're looking for, but under Tools | Global Options... (alt-TG) there is a way to set the default directory. 回答2: Session -> Set

JavaScript: Read files in folder

那年仲夏 提交于 2019-12-18 04:45:08
问题 EDIT: I'm trying to read all the files in a specific folder and list the files in there, not read the content of a specific file. I just tried to simply create an FileSystemObject and it doesn't do anything either. I show an alert (which pops up) beforfe making the FileSystemObject, and one after it (which isn't shown). So the problem is in simply creating the object. Original: I am trying to read all the files in a folder by using JavaScript. It is a local HTML file, and it will not be on a

How to list text files in the selected directory in a listbox?

烈酒焚心 提交于 2019-12-18 04:41:41
问题 How can I list the text files in a certain directory (C:\Users\Ece\Documents\Testings) in a listbox of a WinForm(Windows application)? 回答1: // What directory are the files in?... DirectoryInfo dinfo = new DirectoryInfo(@"C:\TestDirectory"); // What type of file do we want?... FileInfo[] Files = dinfo.GetFiles("*.txt"); // Iterate through each file, displaying only the name inside the listbox... foreach( FileInfo file in Files ) { listbox1.Items.Add(file.Name); } // A statement, followed by a

Copying list of files from one folder to other in R

大兔子大兔子 提交于 2019-12-18 04:35:08
问题 I am trying to bulk move files of different kinds in R. origindir <- c("c:/origindir") targetdir <- c("c/targetdir") filestocopy <- c("myfile.doc", "myfile.rda", "myfile.xls", "myfile.txt", "myfile.pdf", "myfile.R") I tried the following, but do not know how to do for all files: file.copy(paste (origindir, "myfile.doc", sep = "/"), paste (targetdir, "myfile.doc", sep = "/"), overwrite = recursive, recursive = FALSE, copy.mode = TRUE) I do not know how to do this. 回答1: As Joran and Chase have

Directory Modification Monitoring

别等时光非礼了梦想. 提交于 2019-12-18 04:16:26
问题 I'm building a C# application that will monitor a specified directory for changes and additions and storing the information in a database. I would like to avoid checking each individual file for modifications, but I'm not sure if I can completely trust the file access time. What would be the best method to use for getting recently modified files in a directory? It would check for modifications only when the user asks it to, it will not be a constantly running service. 回答1: Hmm... interesting