file-type

C: <sys/stat.h> functions S_ISLNK, S_ISDIR and S_ISREG behaving oddly?

对着背影说爱祢 提交于 2019-12-24 00:53:25
问题 The code this is taken from compiles fine. It prints file names in a directory with the option of a letter in front of it: either a d , f , l , or o depending on their file type ( o for other). However, I tested it on the directory /etc/network which has a symbolic file called run and it appeared as d ? I've tried re-arranging the order of the if-statements too, but that gives an unsatisfactory output too. Am I using it incorrectly? while ((ent = readdir (dp)) != NULL) { lstat(ent->d_name,

Grabbing the openFileEvent on MacOSX (Can't get filename)

核能气质少年 提交于 2019-12-23 18:48:52
问题 We have a Java app on the Mac set to where you double click our custom extension, it opens the app, and then the app does work on the file you clicked. The problem is that I cannot get the "open event" that apple uses in OSX, and so I cannot get the filename (and location) to do the work on. I tried everything I could find using Google, so I must be doing something inherently wrong. Here is the class I call right at the start the application. I just make a new class, and then grab the files a

Validating filetype and display image preview using jQuery

感情迁移 提交于 2019-12-23 04:07:29
问题 I have two scripts that work fine on their own, one validates that the file selected is a jpeg and then outputs a alert, which is given below: (function($) { $.fn.checkFileType = function(options) { var defaults = { allowedExtensions: [], success: function() {}, error: function() {} }; options = $.extend(defaults, options); return this.each(function() { $(this).on('change', function() { var value = $(this).val(), file = value.toLowerCase(), extension = file.substring(file.lastIndexOf('.') + 1

How can I programatically set the default browser in Windows 10

纵饮孤独 提交于 2019-12-22 04:42:44
问题 I want be able to change the default browser (and other associations) via a C# program similar to how browsers have a "Make Browser As Default" option. I've tried changing HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice but Windows just detects tampering, even if I restore both the Hash and ProgId to a previous value. Seems Hash is unique, time based 回答1: You can do this by running a little program I wrote called Set Default Browser. 回答2: There

How can I tell if an extensionless image is png or jpeg

瘦欲@ 提交于 2019-12-21 17:19:54
问题 A while ago I saved some images generated by a web service so the file names are e.g 'ysauyft87ggsa67fgeg&w=1600'. I can open and manipulate these images OK, I'd just like to know what encoding they are (it's almost certainly png or jpeg). I've tried 'get info' in OSX, but it thinks the files are just text (even though it generates thumbnails correctly and I can view the images in preview). If I serve the images on a server they are delivered as 'application/octet-stream'. How can I easily

determine version of microsoft office with java

时光毁灭记忆、已成空白 提交于 2019-12-19 03:53:06
问题 I wrote a program that creates a set of data that is outputted to an excel spreadsheet. I was originally using the jexcel library to write the data to the file, but I'd like to update the program so that it can check and see whether is should create a ".xls" or ".xlsx" file, then write to the appropriate document type. Apache POI seems to be the best option in terms of writing to a ".xlsx" file, but any ideas about determining the correct file type? I could just have the user choose when

How to make Vim detect filetype from shebang line?

别来无恙 提交于 2019-12-18 10:49:12
问题 Sometimes I write scripts without any filename extension. For example: #!/usr/bin/env node console.log('hello world!'); I hope that Vim can detect the filetype from the shebang line (e.g. #!/usr/bin/env node is javascript ). What should I put into filetype.vim ? 回答1: Following the instructions listed in :help new-filetype-scripts, create the scripts.vim file in the user runtime directory ( ~/.vim on Unix-like systems), and write the following script in it. if did_filetype() finish endif if

Best way to organize filetype settings in .vim and .vimrc?

半世苍凉 提交于 2019-12-18 09:55:20
问题 I'm going through my vim dotfiles to tidy them up. I've noticed that through time I've added various filetype specific settings in various inconsistent ways. Let's suppose I'm customizing for Python: au BufRead,BufNewFile *.py (do something) . I don't like this because some Python files might not have the .py termination. au FileType python (do something) . This seems a better option because it doesn't depend on the file having the .py termination. The drawback is that Vim doesn't know about

Allow a custom file to double click and open my application while loading it's data [duplicate]

巧了我就是萌 提交于 2019-12-18 07:06:53
问题 This question already has answers here : How to associate a file extension to the current executable in C# (9 answers) Closed 5 years ago . Just like when you make a reference in windows, to open a .txt file, it may open NotePad.exe and or Word.exe, while loading the text from the file into the editor. How can I do this with my Desktop Application. I am having a custom file type for it with extension .mmi. I want it so that when the user double click this file type it will not only open my

Indicate programming language in a file without extension

放肆的年华 提交于 2019-12-18 03:34:09
问题 When writing executable scripts, and declarative configuration files that use a common language (eg. Python), I often find it undesirable to add an extension to the file name. Many syntax-highlighting text editor (eg. Geany) are subsequently unable to automatically determine the filetype. Is there any standard method for indicating to editors the type of source in the file? 回答1: Typically the shebang line is used as a fall-back. For example, a Ruby script without an extension would begin with