Questions tagged [os-agnostic]

Programs, scripts or procedures that work the same way regardless of the underlying operating system.

In work, open source and pet projects sometimes we need to make programs, scripts and/or procedures work regardless of the underlying operating systems and/or libraries. Some examples of differences that should be overcome are:

  • path separator character (\ in Windows, / in Unix derivatives);
  • availability of certain command line tools;
  • need/desire to use a native functionality for a given task (for example for better performance).

At a high level, these problems can be solved in the following ways:

  • by using functionalities that abstracts these differences;
  • by testing directly the presence of a feature. An example of this is Javascript feature detection;
  • by detecting the environment and act differently according to the detected environment. An example of this is documented by Martin Fowler in his article about Rake (in particular see the section about the use native XSLT engines).
20 questions
389
votes
36 answers

How do you convert an entire directory with ffmpeg?

How do you convert an entire directory/folder with ffmpeg via command line or with a batch script?
Eugene
  • 10,957
  • 20
  • 69
  • 97
331
votes
14 answers

OS detecting makefile

I routinely work on several different computers and several different operating systems, which are Mac OS X, Linux, or Solaris. For the project I'm working on, I pull my code from a remote git repository. I like to be able to work on my projects…
samoz
  • 56,849
  • 55
  • 141
  • 195
58
votes
8 answers

Command line batch image cropping tool

is there any lightweight command line batch image cropping tool(Linux or Windows) which can handle a variety of the formats ?
iceman
  • 4,211
  • 13
  • 65
  • 92
11
votes
1 answer

How to access the file path separator for the current platform?

Are there any available option to get platform specific file separator in Rust? There can be different platform specific separators: let separator = "\\" // Could be this. let separator2 = "/" // Could be this. let separator3 = "//" // Could be…
Akiner Alkan
  • 6,145
  • 3
  • 32
  • 68
8
votes
2 answers

tell if make is running on windows or linux

Is there a way to know in makefiles if GNU make is running on a linux OS or a windows OS? I've built a bash script that generates a makefile for building my app and it works fine on my Debian machine. I want to try to build it on MinGW/MSYS, but the…
Gianni Pisetta
  • 293
  • 1
  • 2
  • 8
8
votes
1 answer

Creating an in-memory cache that persists between executions

I'm developing a Python command line utility that potentially involves rather large queries against a set of files. It's a reasonably finite list of queries (think indexed DB columns) To improve performance in-process I can generated…
dimo414
  • 47,227
  • 18
  • 148
  • 244
5
votes
2 answers

How to increase the stack size available to a Rust library?

I am playing with lambda calculus and would like to have a bit more stack space to be able to build and compute (very) long function chains. Is there a way to increase it for the crate, similar to increasing the recursion limit (#![recursion_limit =…
ljedrz
  • 20,316
  • 4
  • 69
  • 97
3
votes
1 answer

Do all programs need to have a stack and a heap?

Most if not all programs nowadays have a "stack" for objects with a size known at compile time, and a "heap" for dynamically allocated objects. Where is this implemented in practice? Is at the CPU, OS, or program level? Does every program have to…
Null User
  • 338
  • 1
  • 4
  • 17
3
votes
9 answers

How a servlet can get the absolute path to a file outside of the servlet?

We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file…
WolfmanDragon
  • 7,851
  • 14
  • 49
  • 61
3
votes
1 answer

Get FileStore object for any given path

Edit: I recognize that FileSystem.getDefault() will give me what I was looking for in my original question statement. I am attempting to use FileSystem.getFileSystem(URI) to get the FileSystem for any given path. I am attempting to develop some code…
Chuck Wolber
  • 519
  • 7
  • 15
2
votes
1 answer

Is there an OS independent way to poll TOTAL and/or USED video memory?

I'm looking for a way to poll for total video memory on board a graphics cars / integrated chipset. I'm aware of WMI assisted polling under Windows, and as far as I understand that information is constructed on every boot by WMI. However, being an…
Keyframe
  • 1,390
  • 1
  • 14
  • 28
2
votes
2 answers

Logging: How to set the newline character of log files?

I'm using logging on Python 3.7+ on both Windows and Linux, yet the line ending depends on the platform. While you can set the newline character when reading or writing a file, obviously you cannot when setting a logging.FileHandler…
Kochise
  • 504
  • 5
  • 10
2
votes
1 answer

Can a project support both Autotools and Cmake at the same time?

I happen to think (but maybe is a myth) that Cmake is greater than Autotools about making easy supporting Microsoft. At the same time, I'm kind of sure that Autotools is even more straightforward than Cmake when it comes to important UNIX…
1737973
  • 159
  • 18
  • 42
1
vote
1 answer

Consistency guarantee of file system regarding sequential write

My program (only 1 process and 1 thread) sequentially write n consecutive chunks of data to a file on a HDD (regular kind of HDD) using plain old write system call. It's like some kind of append-only log file. After a system crash (power failure,…
1
vote
2 answers

Operating system independent image addressing

Due to using both Windows and Ubuntu on my computer I'd like to be able to create documents independently. I have one directory for logos and I want to use them in any documents everywhere. The problem with different file addressing I solved with…
Crowley
  • 2,279
  • 6
  • 22
  • 36
1
2