directory

Determine file/folder in C

泄露秘密 提交于 2021-01-28 21:50:04
问题 I have the following code in C: DIR *mydir = opendir("/"); struct dirent *entry = NULL; while((entry = readdir(mydir))) { printf("%s\n", entry->d_name); //printf("%i\n", entry->d_type); } closedir(mydir); It works and shows the files/folders in the location, correctly. However, I want to tell if it is a folder or a file. How can I do this? I tried with d_type (as you can see on the code) but no success. 回答1: Use stat(): struct stat st; stat("nodename", &st); int isDirectory = S_ISDIR(st.st

Deleting duplicate files if file exists in certain directories - python

与世无争的帅哥 提交于 2021-01-28 19:52:47
问题 I have 3 folders - 1 master and 2 supplemental. I am writing a script that identifies duplicate files in all three via SHA1 hashing. For any duplicates found in master and supplementals (or their subdirectories), I would like to delete the files in the supplemental folders and keep the files in the master folder. If duplicate files are found in the supplemental folders and not the master folder, I would like to keep them and eventually merge with the master. I have written a script (below)

SavedModel file does not exist when using Tensorflow hub

六眼飞鱼酱① 提交于 2021-01-28 19:35:41
问题 When trying to use the hub.load function from tensorflow_hub , I get an OSError: SavedModel file does not exist at: error. The weird thing is that it worked a few days ago, so I don't quite understand why I'm getting this error now. Code to reproduce: import tensorflow as tf import tensorflow_hub as hub URL = 'https://tfhub.dev/google/universal-sentence-encoder/4' embed = hub.load(URL) Specific error received: OSError Traceback (most recent call last) <ipython-input-11-dfb80f0299b2> in

Java JTree from directory (shows full path instead of just the name of the file)

浪尽此生 提交于 2021-01-28 18:13:59
问题 I wanted to make a tree from an existing directory, so that it shows all of the subfolders and files inside. I did it with this code: File file = new File(path); TreeModel model = new FileTreeModel(file); JTree tree = new JTree(model); But now it shows the full path instead of just the folder/file name. If you don't know what I mean, this might help: Please help... I wanted to find the solution online but I didn't know how to describe the problem. :/ 回答1: import java.io.File; import java.util

recursive folder reading with java.io.File

大憨熊 提交于 2021-01-28 17:47:45
问题 Currently I create a list of sub folders with this function: % create list of all sub folders dirs = regexp(genpath(basePath),['[^;]*'],'match'); My folders contain however > 100 000 files. This function takes minutes to hours to complete. The number of folders however is only < 100. I read that java.io.File is magnitudes faster. However how can I use it to read folders recursive? jFile = java.io.File([basePath '*']); %java file object jPaths = jFile.listFiles; %java.io.File objects jNames =

recursive folder reading with java.io.File

送分小仙女□ 提交于 2021-01-28 17:45:07
问题 Currently I create a list of sub folders with this function: % create list of all sub folders dirs = regexp(genpath(basePath),['[^;]*'],'match'); My folders contain however > 100 000 files. This function takes minutes to hours to complete. The number of folders however is only < 100. I read that java.io.File is magnitudes faster. However how can I use it to read folders recursive? jFile = java.io.File([basePath '*']); %java file object jPaths = jFile.listFiles; %java.io.File objects jNames =

React import folder navigation

淺唱寂寞╮ 提交于 2021-01-28 11:52:24
问题 I am trying to import images from an assets folder in my src folder in my react app but for some reason the path is not being recognised. My folder structure is as follows: |src |Assets |Common |Components I am trying to import the image located in the assets folder from the components folder. I was able to import from my common folder to files in the components folder by doing the following: import * as Constants from '../Common/Constants'; However following this same structure for loading

C# File change/create/delete event

余生长醉 提交于 2021-01-28 11:42:51
问题 im currently getting into security stuff and trying to build a basic "access limiter" which should register if a file or folder in a specific directory (including subdirectories) is created, changed, deleted etc. I already figured out how to do it after the action took place using FileSystemWatcher , but I want to catch the request / event before it happens to process it. I already searched a while but haven`t really found a solution yet. If something like this is possible I would be grateful

Searching for files in a directory by name using Visual Studio C++

徘徊边缘 提交于 2021-01-28 11:09:23
问题 I'm trying to create a program where I can search for some files in a directory on my PC, using Visual Studio C++. As I'm not very experienced with that, I found this code (below) in another answer but couldn't find any explanation to the code. I'm having a hard time figuring it out and would strongly appreciate any help possible. If there's another way of doing this I would be pleased to know how. Thank you! " Now you can get file names. Just compare a file name. while ((dirp = readdir(dp))

How do I gain access to the documents folder (UWP)

人走茶凉 提交于 2021-01-28 10:51:46
问题 When closing the UWP I will get a list of items from a database. I want to save this list in a file which will be created/edited in the documents folder. I tried to gain access to the Documents folder by this: StorageFolder stFo = KnownFolders.DocumentsLibrary; My Problem is that I have no access to the Documents Folder ('An exception of type "System.UnauthorizedAccessException" occured...'). Now I have read that you could get access by adding some lines to Package.appxmanifest <Package xmlns