TagLib# Exception on File.Create - taglib-sharp

I am trying to use Taglib# to add id3v2 tags to a file.
I have it working on some files - however, on certain files it will fail. (Possibly due to file corruption).
if (ext == ".aiff" || ext==".aif"){
//force reading of aiff files
file = TagLib.File.Create(filename, "audio/aiff",TagLib.ReadStyle.None);
}
The Create() call throws this exception:
Provided data does not start with the file identifier
Based on the documentation, I'm not sure how I can fix this (or add a file identifier).

Not sure there was a way to do this. The solution was to run the files through FFMPEG and create new AIFF so that they would produce PROPER AIFF files. Then TagLib# works properly.

Based on my own experiments, TagLib Sharp also throws exception on the Create() method "if" corresponding file has no ID3 tag at all. I just tested with some files, removed tags using TagLib Sharp, then tried the Create() method on the same file; same exception happened.

Related

How to use custom language highlight syntax in Gtk SourceView?

I'm trying to create my own language definition, and use it for highlighting the syntax in my app.
The issue I have is that, when trying to access the language definition from my app's data folder (/usr/share/myapp/), even using the c.lang file copied from /usr/share/gtksourceview-3.0/language-specs/, just to test, I get this error at runtime:
GtkSourceView-WARNING **: Failed to load '/usr/share/myapp/c.lang': could not find the RelaxNG schema file
So it's asking for some schema file? So I went forward and copied every file from the language-specs folder that isn't a lang file, which includes: language.dtd, language.rng and language2.rng.
Now, when I run again, I get these errors:
GtkSourceView-WARNING **: in file /usr/share/com.github.aleksandar-stefanovic.urmsimulator/c.lang: style 'def:comment' not defined
GtkSourceView-WARNING **: Failed to load '/usr/share/com.github.aleksandar-stefanovic.urmsimulator/c.lang': unable to resolve language 'def'
What does that even mean? Is that something namespace-related? It is very peculiar, because the exact same file is working perfectly when in gtksourceview folder.
Any clues? Do these "RelaxNG" files work only in their original directories? If so, how can I change that? I've looked into the files, but failed to find any reference to their original folder...
This is the source-code (in Vala) related to the issue:
var manager = Gtk.SourceLanguageManager.get_default ();
string search_paths[] = {"/usr/share/myapp", null};
manager.set_search_path (search_paths);
var buffer = new Gtk.SourceBuffer.with_language (manager.get_language ("c"));
The application does in fact find the language "c", I've checked by debugging.
You have to preserve the Gtk.SourceLanguageManager's original search path when you add your own. Append to it instead of replacing it.

How can I rename file uploaded to s3 using javascript api?

'pickAndStore' method allows me to specify full path to the file, but I don't know it's extension at this point (file path has to be defined before file is uploaded, so it's not possible to provide a path with correct extension).
if I use 'pick' and then 'store' I have 2 files (because both methods uploads file to the s3). I can delete 'old' file, but it's not optimal and can be pain (take ages) with really big files.
Is there any better solution? Ideally to rename existing file.
Currently, there is no workaround for renaming file.
However, in our Javascript API v2 we are planing to add new callback function. onStart callback will be fired after user pick file but before file uploading. There could be option like renaming file based on original filename.
We will keep you updated.

Include file as input stream in scala

I'm having problems with using a file in my code. I'm working with javaPNS and trying to get it to work. What I think is wrong now is how I get my file for the keystore parameter in the Push.alert method in javaPNS.
What I'm really wondering is how do I "get a resource" properly so it has the correct format?
Here's the exception that is thrown:
javapns.communication.exceptions.InvalidKeystoreReferenceException:
Invalid keystore parameter (null). Must be InputStream, File, String (as a file path),
or byte[].
at........
And here's how I currently include the file:
val keystoreFile = getClass.getResourceAsStream("/app/conf/cert.p12")
If we look at the exception I get, do you think this above is the problem? How should I include the file properly in Scala?
regards,
The problem you are seeing has to do with the fact that the InputStream you are loading is coming back as null. This happens when the file you are trying to load can not be found on the class path. Try changing your code to:
getClass.getClassLoader.getResourceAsStream("app/conf/cert.p12")
You will notice I removed the leading slash on the file path as I believe this is your issue. Then just make sure that whatever the parent directory to "app" is is on your class path.

Allow for non-existent files in FileFieldEditor [duplicate]

I'm setting up a series of preferences in my Eclipse (3.5.2) application and I'm having a problem with the FileFieldEditor. I want to allow the user to specify a log file to print output to. Often, this will be a new file. But when I use the file select dialog with FileFieldEditor, it complains that the file doesn't exists ("Value must be an existing file"). Is there a way, without extending the FileFieldEditor class, to suppress this error and have Java create that file if it doesn't exist? Thanks!
When I look the source code of org.eclipse.jface.preference.FileFieldEditor, the only solution would be to extend it and write your own version of a FileFieldEditor, with:
an overwritten changePressed() method in order to keep the file path even if the file does not exists
an overwritten checkState() method in order to avoid that error message.
So I do not see a way to avoid that FileFieldEditor extension here.

How to add an extra plist property using CMake?

I'm trying to add the item
<key>UIStatusBarHidden</key><true/>
to my plist that's auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; for example:
set(MACOSX_BUNDLE_ICON_FILE ${ICON})
But I can't find a way to add an arbitrary property.
I tried using the MACOSX_BUNDLE_INFO_PLIST target property as follows: I'd like the resulting plist to be identical to the old one, except with the new property I want, so I just copied the auto-generated plist and set that as my template. But the plist uses some Xcode variables, which also look like ${foo}, and CMake grumbles about this:
Syntax error in cmake code when
parsing string
<string>com.bedaire.${PRODUCT_NAME:identifier}</string>
syntax error, unexpected cal_SYMBOL,
expecting } (47)
Policy CMP0010 is not set: Bad
variable reference syntax is an error.
Run "cmake --help-policy CMP0010"
for policy details. Use the
cmake_policy command to set the
policy and suppress this warning. This
warning is for project developers.
Use -Wno-dev to suppress it.
In any case, I'm not even sure that this is the right thing to do. I can't find a good example or any good documentation about this. Ideally, I'd just let CMake generate everything as before, and just add a single extra line. What can I do?
Have you looked into copying the relevant *.plist.in file in /opt/local/share/cmake-2.8/Modules (such as MacOSXBundleInfo.plist.in), editing it to put <key>UIStatusBarHidden</key><true/> (or #VAR_TO_REPLACE_BY_CMAKE#), and adding the directory of the edited version in the CMAKE_MODULE_PATH?
If you have CMake installed as an app bundle, then the location of that file is /Applications/CMake.app/Contents/share/cmake-N.N/Modules
You can add your values using # and pass #ONLY to configure_file.
Unfortunately there is no simple way to add custom line to generated file.