subdirectory

How to list all subdirectories in a given directory in C?

喜夏-厌秋 提交于 2019-12-04 05:51:08
Is there a way to list all subdirectories in a given directory path in C? I was hoping I would be able to do it with the stat() function but it only works on files. CodingLab stat works on directories too. #include <sys/types.h> #include <dirent.h> #include <sys/stat.h> #include <unistd.h> int num_dirs(const char* path) { int dir_count = 0; struct dirent* dent; DIR* srcdir = opendir(path); if (srcdir == NULL) { perror("opendir"); return -1; } while((dent = readdir(srcdir)) != NULL) { struct stat st; if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; if (fstatat

SAF - Invalid URI error from DocumentsContract.createDocument method (FileOutputStream copy)

∥☆過路亽.° 提交于 2019-12-04 05:50:24
问题 My app is migrating to SAF or, at least some experimentation is going about. Now it has to copy a file from private app folder to a SAF folder that was authorized. The used method is: static boolean copyFileToTargetFolderWithNewName(Activity activity, String filePath,String targetFolderUri,String newName) { File file = new File(filePath); FileInputStream fis=null; Uri docUri=null; try { fis=new FileInputStream(file); } catch (FileNotFoundException e) { return false; } deleteIfExisting

cakephp inside a subdirectory

主宰稳场 提交于 2019-12-04 05:45:09
问题 I have a problem with cakephp, I can't find a way to get cakephp working in a subdirectory. I have a webpage that resides at www.example.com and I want to have cakephp application on www.example.com/cake . www.example.com is a virtual host and cake is it's subdirectory where all of the cake files and directories are stored. The problem is that when I go to www.example.com/cake it requests a CakeController and has no stylesheets loaded. When I go to www.example.com/cake/users/register (=

What is the maximum allowed depth of sub-folders?

。_饼干妹妹 提交于 2019-12-04 05:14:43
At first I wanted to ask "What is the maximum allowed sub-folder for a windows OS" But then I figured maybe my web hosting provider isn't on windows but on linux or something else. So I'm asking what are the possible maximum allowed sub-folder for all major OS that a Web Hosting Provider would usually use. (Would it be safe to say Linux, Mac, or Windows?) Then again, based on your experiences, do web hosting sites create a limit to the number of subfolders we can make? (Why this? Because I want each user to have their very own folder for easy access to their images. Would that be ok? Or is it

Get all URLs for resources in sub-directory in Swift

末鹿安然 提交于 2019-12-04 04:32:52
I am attempting to create an array of URLs for all of the resources in a sub-directory in my iOS app. I can not seem to get to the correct path, I want to be able to retrieve the URLs even if I do not know the names (i.e. I don't want to hard code the file names into the code). Below is a screen shot of the hierarchy, I am attempting to get all the files in the 'test' folder: Any help is greatly appreciated, I have attempted to use file manager and bundle main path but to no joy so far. This is the only code I have currently: let fileManager = FileManager.default let path = Bundle.main.urls

nginx serving Django in a subdirectory through uWSGI

旧城冷巷雨未停 提交于 2019-12-04 02:53:50
I have already gone through some previous threads: How do I set subdirectory in nginx with Django how to deploy django under a suburl behind nginx Serving flask app on subdirectory nginx + uwsgi The basic lesson is that you should only need to configure your site(s-available) to achieve this. I have now tried various permutations of server { listen 80; server_name www.example.com; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /path/to/project; } location /project/ { root /path/to/project; include /etc/nginx/uwsgi_params; uwsgi_param SCRIPT_NAME

Making a list of folders in a directory with wxWidgets

微笑、不失礼 提交于 2019-12-04 01:54:17
问题 I'm making an application with wxWidgets that has a listbox in it. I want to get the current working directory of the application, and in that listbox, list all the folders names (not full paths) in the cwd that contain a specific file. I've already figured out how to get the cwd and return it as a wxString (not that I'm particularly sure it's working, but I'll find out soon enough) but I'm not sure how to get the list of folders and pass it to the listbox. I'm brand new to wxWidgets, and

Create a new repo from sub folder in Mercurial Repo using convert

依然范特西╮ 提交于 2019-12-04 00:41:07
I am trying to extract a folder (call it Project1 ) from an existing Mercurial Repo (call in MainRepo ) using the Convert extension for Mercurial to Mercurial conversion. I have followed the methods described by Mercurial developers (and elsewhere on the web) under Windows XP: C:\MainRepo>echo include Project1 > ~myfilemap C:\MainRepo>echo rename Project1 . >> ~myfilemap C:\MainRepo>hg convert --filemap ~myfilemap . C:\Project1Repo C:\MainRepo>cd \Project1Repo C:\Project1Repo>hg update This creates the new repo (Project1Repo) with the Mercurial folder/files in place. But it does not: 1) Carry

python os.walk to certain level [duplicate]

左心房为你撑大大i 提交于 2019-12-03 17:31:13
问题 This question already has answers here : Travel directory tree with limited recursion depth (2 answers) Closed 2 years ago . I want to build a program that uses some basic code to read through a folder and tell me how many files are in the folder. Here is how I do that currently: import os folders = ['Y:\\path1', 'Y:\\path2', 'Y:\\path3'] for stuff in folders: for root, dirs, files in os.walk(stuff, topdown=True): print("there are", len(files), "files in", root) This works great until there

Python zip a sub folder and not the entire folder path

谁说我不能喝 提交于 2019-12-03 13:08:09
I have a program to zip all the contents in a folder. I did not write this code but I found it somewhere online and I am using it. I intend to zip a folder for example say, C:/folder1/folder2/folder3/ . I want to zip folder3 and all its contents in a file say folder3.zip. With the below code, once i zip it, the contents of folder3.zip wil be folder1/folder2/folder3/and files. I do not want the entire path to be zipped and i only want the subfolder im interested to zip (folder3 in this case). I tried some os.chdir etc, but no luck. def makeArchive(fileList, archive): """ 'fileList' is a list of