file-extension

count number of files with a given extension in a directory - C++?

淺唱寂寞╮ 提交于 2019-12-01 09:37:31
Is it possible in c++ to count the number of files with a given extension in a directory? I'm writing a program where it would be nice to do something like this (pseudo-code): if (file_extension == ".foo") num_files++; for (int i = 0; i < num_files; i++) // do something Obviously, this program is much more complex, but this should give you the general idea of what I'm trying to do. If this is not possible, just tell me. Thanks! There is nothing in the C or C++ standards themselves about directory handling but just about any OS worth its salt will have such a beast, one example being the

Working with multiple source file extensions in a makefile

牧云@^-^@ 提交于 2019-12-01 01:14:15
问题 I have a c++ project with various extensions for the source files (.cpp, .c, .cc) and various extensions for the header files (.hpp, .h, .hh). The source files are located in a directory called SRC, and the header files are predictably in a directory called INC. I would like to compile the source with a rule like vpath %.c $(SRC) %.o: %.c $(COMPILER) $(FLAGS) $< $(INCFLAG)$(INC) This of course works if I know the source file will be of the form %.c, but in the case of multiple possible file

Android Share custom file

浪尽此生 提交于 2019-12-01 00:34:09
I created my own file extension ( .oli ). If the user clicks on a file with this extension my app starts and loads the included data. This works like expected. The problem is I would like to give the user of my app the opportunity to share a file (Example: filename.oli). I implemented this so far: public void shareFile(){ File file = getShareableFile(); //Creates a .oli-file Intent shareIntent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.fromFile(file); shareIntent.setType("*/*"); //Maybe the problem shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(android.content.Intent

android browse file intent with defined extension

会有一股神秘感。 提交于 2019-11-30 23:10:35
问题 I need to create intent that will open file manager (if any installed) and I want file manager to show only txt files to user, so user couldn't choose file with wrong extension. private static final int FILE_SELECT_CODE = 0; private void showFileChooser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); try { startActivityForResult( Intent.createChooser(intent, "Select txt file"), FILE_SELECT_CODE); } catch (android

PHP include file extensions?

こ雲淡風輕ζ 提交于 2019-11-30 17:59:41
问题 For required/included files in PHP, is it better to use .inc extensions vs .inc.php vs .php extensions? 回答1: Sometimes people use the .inc extension and then do some server configuration to keep .inc files from being accessed via a web browser. This might be good, if done absolutely correctly by a knowledgeable sysadmin, but there's a better way: Any file that's not supposed to be accessed by web users should be kept outside your document root. Once these files are off the web, so to speak,

Enabling and disabling word wrap automatically on different file extensions on Vim

懵懂的女人 提交于 2019-11-30 17:20:46
问题 I usually have to read .txt files with long lines, and at the same time edit some source file, and I like to see word wrap on the .txt files, and not in the ones that aren't. Of course I can :set wrap and :set linebreak, but is there any way to make it automatucally, and dependent of the file extension? 回答1: I guess :autocmd BufNewFile,BufRead *.txt set wrap should do the trick 回答2: There are two options that I can think of. Firstly, you can use an autocmd as suggested by Tassos: :au

Finding a file with a specific name with any extension

*爱你&永不变心* 提交于 2019-11-30 13:22:43
Please note that I want the compartment number to change. <?php $compartment = "1"; /* HERE I NEED SOME SCRIPT TO FIND THE EXTENSION OF THE FILE NAME $compartment AND TO SAVE THAT AS A VARIABLE NAMED 'EXTENSION'.*/ if (file_exists($compartment.$extension)) { echo "$compartment.$extension exists! } else { echo "No file name exists that is called $compartment. Regardless of extension." } ?> <?php $compartment = "2"; /* HERE I NEED SOME SCRIPT TO FIND THE EXTENSION OF THE FILE NAME $compartment AND TO SAVE THAT AS A VARIABLE NAMED 'EXTENSION'.*/ if (file_exists($$compartment.$extension)) { echo "

What is the difference between php and html file extensions?

 ̄綄美尐妖づ 提交于 2019-11-30 13:12:53
I am having a .php file with the following code. While I am changing the extension of the file as .html then also it is behaving in the same way. Can anyone explain the following: Why the file is behaving in the same manner with both the extensions? What is the difference between the .php and .html file extensions? .php file <html> <head> <!-- some html code --> </head> <body> <?php echo "Hello!" ?> </body> </html> The filetype is just a way to identify the file, you can't always trust them. Depending on your web server configuration, you will see different results. .html is generally use just

Can I use images without extension in <img>? [duplicate]

丶灬走出姿态 提交于 2019-11-30 13:00:26
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Is it safe to serve an image on the web without an extension? I'd like to use something like <img src="advertisements/12" style="border: 1px solid"> in a page. FireFox won't display it, which makes me think I have to have a file extension for the file. Am I right here (for the other browsers too), or does FF like mime types? EDIT I've tried all sorts of stuff and it still won't work. I now put an extension on

Which programming language has extension .do

空扰寡人 提交于 2019-11-30 11:12:08
问题 Just wondering which programming languages is used on the web pages with the extension ".do" 回答1: According to FileInfo, the file extension is for Java Servlets. 回答2: Strictly speaking, you can't tell for sure just by looking at the extension. I can configure a web server to interpret *.do URLs as referring to PHP files or even executables and run it accordingly. In fact, *.do URLs may not even refer to files at all! It really does depend on how the server is configured. 回答3: That is