filesystem-access

Why does Linux use getdents() on directories instead of read()?

给你一囗甜甜゛ 提交于 2021-02-06 11:22:30
问题 I was skimming through K&R C and I noticed that to read the entries in a directories, they used: while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dirbuf)) /* code */ Where dirbuf was a system-specific directory structure, and dp->fd a valid file descriptor. On my system, dirbuf would have been a struct linux_dirent . Note that a struct linux_dirent has a flexible array member for the entry name, but let us assume, for the sake of simplicity, that it doesn't. (Dealing with the

Why does Linux use getdents() on directories instead of read()?

南笙酒味 提交于 2021-02-06 11:21:31
问题 I was skimming through K&R C and I noticed that to read the entries in a directories, they used: while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dirbuf)) /* code */ Where dirbuf was a system-specific directory structure, and dp->fd a valid file descriptor. On my system, dirbuf would have been a struct linux_dirent . Note that a struct linux_dirent has a flexible array member for the entry name, but let us assume, for the sake of simplicity, that it doesn't. (Dealing with the

C# .Net Freeze while iterating through large number of files

試著忘記壹切 提交于 2020-01-06 16:19:42
问题 I have a problem that I wrote an application that would iterate through files and add +1 to the integer each file, until it reaches a specific file name. The problem is probably because .Net does not access the native file system directly, it fills up collections, but in my case it would take years, believe me, I have 260 000 files in the target folder. The iteration does not even reach the second file. The thread just totally freezes, no errors, no exceptions. So is there any way to get a

Is it possible to use 'fs' (filesystem) module inside page executed by PhantomJS?

混江龙づ霸主 提交于 2019-12-25 05:36:08
问题 I want to have access to filesystem on a page that is rendering by PhantomJS headless browser. I catch an error when JS code is trying to interact with filesystem var fs = require('fs'); ... ReferenceError: Can't find variable: require Is there some hack/plugin to PhantomJS that allows to do that? P.S. I'm using headless tests runner based on PhantomJS (teaspoon) and I want to store some data from tests on filesystem. 来源: https://stackoverflow.com/questions/30779915/is-it-possible-to-use-fs

How I can access resources of local filesystem and manipulate them from browser

扶醉桌前 提交于 2019-12-20 07:30:06
问题 I need a technology to: a) From the a browser, a web page, browse to the user filesystem (with his authorization) b) Let user select a folder and search for images c) The folder can contain huge jpg images (up to 20Mb) d) show a resized version , very tiny version, of the founded images inside the browser e) play with the thumbnail (reorder, rename, associate some options), interacting with the web pages f) let the user select which image will be uploaded g) when finished upload all the huge

Redirect file access

柔情痞子 提交于 2019-12-13 02:27:43
问题 Is there a way to monitor and redirect file access of a thread or process? For example a thread wants to read /etc/mysql/my.cnf and I want to change the access to ~/my.cnf or if I run touch /etc/test.config I want the file to be redirected to ~/somefolder/etc/test.config . I am looking for a libary preferably for C, C++ which works for Linux/Unix. Thanks in advance 回答1: You could write a shared object that gets pre-loaded when your program starts running. In the .so you'd redefine the libc

How I can access resources of local filesystem and manipulate them from browser

一世执手 提交于 2019-12-02 09:46:15
I need a technology to: a) From the a browser, a web page, browse to the user filesystem (with his authorization) b) Let user select a folder and search for images c) The folder can contain huge jpg images (up to 20Mb) d) show a resized version , very tiny version, of the founded images inside the browser e) play with the thumbnail (reorder, rename, associate some options), interacting with the web pages f) let the user select which image will be uploaded g) when finished upload all the huge original file size I cannot use external client. No problem for plugins. Is there a technology out

Save images to hard disk WITHOUT prompt?

依然范特西╮ 提交于 2019-11-26 16:42:16
I use twitter. Some people's tweets contain photos and I want to save them. I checked ifttt, where twitter is not a trigger. Thus, ifttt cannot help me do it. One idea is probably to use JavaScript. I use Firefox and installed Greasemonkey. I can write a Greasemonkey script (JavaScript) running on twitter website. Once I click "retweet" link or other button added by my script, my script examines the content of the tweet, find the URL of the photo, and save it to my disk. One problem is how to save the image. I searched the Internet. Some use win.document.execCommand("SaveAs") , and it will

Save images to hard disk WITHOUT prompt?

家住魔仙堡 提交于 2019-11-26 06:48:20
问题 I use twitter. Some people\'s tweets contain photos and I want to save them. I checked ifttt, where twitter is not a trigger. Thus, ifttt cannot help me do it. One idea is probably to use JavaScript. I use Firefox and installed Greasemonkey. I can write a Greasemonkey script (JavaScript) running on twitter website. Once I click \"retweet\" link or other button added by my script, my script examines the content of the tweet, find the URL of the photo, and save it to my disk. One problem is how